[Demonstration 1]

[Buggy Method]
public void fetch(IRSSConf configuration) {
    Fetcher fetcher = new HttpFetcher(httpClient, repository, configuration.getRespectRobots(), configuration.applyHTTPFetchRestrictions());
    String filename = configuration.getUrlsFileName();
    DefaultCrawlIdGenerator idgen = new DefaultCrawlIdGenerator(repository);
    CrawlId CrawlID = idgen.createNewCrawlId();
    ArrayList<String> urls = Utils.readFileLinesDropComments(filename);
    boolean retry = false;
    for (int s = 0; s < urls.size(); s++) {
        String url = urls.get(s);
        try {
            Document doc = null;
            System.out.printf("Fetching url %d/%d : [%s]\n", 1 + s, urls.size(), url);
            try {
                doc = Jsoup.connect(url).get();
            } catch (org.jsoup.HttpStatusException e) {
                //e.printStackTrace();
                System.err.println("\tJsoup http status error. Continuing...");
                continue;
            }
            if (doc == null)
                continue;
            String title = doc.title();
            Date articleDate = DateExtractor.getDate(doc, url);
            Item item = new Item("no-feed", CrawlID);
            Content htmlContent = fetcher.fetchUrl(url);
            if (htmlContent == null) {
                if (retry == false) {
                    System.out.println("\tNull html content, retrying");
                    --s;
                    retry = true;
                }
                continue;
            } else
                retry = false;
            if (title == null) {
                title = "";
            } else {
                title = StringUtils.normalizeSpace(title.replaceAll("\\x7f", " "));
            }
            repository.savePage(item, title, htmlContent, articleDate);
            System.out.println("Saved fetched page " + url);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (BoilerpipeProcessingException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    CrawlID.finishedCrawling();
    repository.saveCrawlId(CrawlID);
}

[Buggy Hunk]
doc = Jsoup.connect(url).get();

[Patch]
doc = Jsoup.connect(url).userAgent("Mozilla").get();

[Demonstration 2]

[Buggy Method]
private String getURL(String url) throws IOException {
    //System.out.print("\nGoing to get: " + url);
    int responseCode = 0;
    URL urlObj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
    con.setRequestMethod("GET");
    //con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
    con.setRequestProperty("Accept", this.mimetype);
    responseCode = con.getResponseCode();
    //System.out.print("\nGET response code: " + responseCode);
    if (responseCode != 200) {
        if (responseCode == 406) {
            System.out.print("\nhttp response 406: unacceptable content type specified: " + this.mimetype);
        }
        if (responseCode == 404) {
            System.out.print("\nhttp response 404: unable to locate stream: " + url);
        }
        System.exit(responseCode);
    }
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine, response = "";
    while ((inputLine = in.readLine()) != null) {
        response = response + inputLine;
        //System.out.println(inputLine);
    }
    in.close();
    return response;
}

[Buggy Hunk]
private String getURL(String url) throws IOException {

[Patch]
public String getURL(String url) throws IOException {

[Demonstration 3]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));