[Demonstration 1]

[Buggy Method]
public static void makeIlluminaConfigFile(IlluminaSampleSheetFile illuminaSampleSheetFile, IlluminaRunParametersFile illuminaRunParametersFile) {
    log.log(Level.INFO, "Writing variable files...");
    StringBuilder analysisDirs = new StringBuilder("AnalysisDirs=( ");
    for (IlluminaSampleSheetRecord record : illuminaSampleSheetFile.getSampleSheetRecords()) {
        analysisDirs.append('"');
        analysisDirs.append(Parameters.getCvxgenResultsRootDir());
        analysisDirs.append("/");
        analysisDirs.append(illuminaRunParametersFile.getRunIdentifier());
        analysisDirs.append('/');
        analysisDirs.append(record.getSampleID());
        analysisDirs.append('"');
        analysisDirs.append(' ');
    }
    analysisDirs.append(')');
    for (int n = 0; n < illuminaSampleSheetFile.getSampleSheetRecords().size(); ++n) {
        try (PrintWriter writer = new PrintWriter(illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleID() + ".variables")) {
            //write variable files
            writer.print("#Illumina Variables File\n");
            writer.print("\n#Run Details\n");
            writer.print("RunID=" + illuminaRunParametersFile.getRunIdentifier() + "\n");
            writer.print("ExperimentName=\"" + illuminaSampleSheetFile.getExperimentName() + "\"\n");
            writer.print("Platform=ILLUMINA\n");
            writer.print("\n#Demographics\n");
            writer.print("SampleID=" + illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleID() + "\n");
            writer.print("\n#FASTQ Filenames\n");
            writer.print("Read1Fastq=" + illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleID() + "_S" + (n + 1) + "_L001_R1_001.fastq.gz\n");
            writer.print("Read2Fastq=" + illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleID() + "_S" + (n + 1) + "_L001_R2_001.fastq.gz\n");
            if (!illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleProject().equals("")) {
                writer.print("\n#Sample Project\n");
                StringBuilder sampleProjects = new StringBuilder("SampleProjects=( ");
                for (String field : illuminaSampleSheetFile.getSampleSheetRecords().get(n).getSampleProject().split(";")) {
                    sampleProjects.append('"');
                    sampleProjects.append(field);
                    sampleProjects.append('"');
                    sampleProjects.append(' ');
                }
                sampleProjects.append(')');
                writer.print(sampleProjects.toString() + "\n");
            }
            writer.print("\n#Sample Descriptors\n");
            for (String field : illuminaSampleSheetFile.getSampleSheetRecords().get(n).getDescription().split(";")) {
                writer.print(field + "\n");
            }
            writer.print("\n#Analysis Folders\n");
            writer.print(analysisDirs.toString() + "\n");
            writer.close();
        } catch (IOException e) {
            log.log(Level.SEVERE, "Could not write variables file: " + e.getMessage());
        }
    }
}

[Buggy Hunk]
analysisDirs.append(Parameters.getCvxgenResultsRootDir());

[Patch]
analysisDirs.append("/data/results");

[Demonstration 2]

[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));

[Demonstration 3]

[Buggy Method]
public static <K, V extends Comparable<V>> Map<K, V> sortByValues(final Map<K, V> map) {
    Comparator<K> valueComparator = new Comparator<K>() {

        public int compare(K k1, K k2) {
            int compare = map.get(k2).compareTo(map.get(k1));
            if (compare == 0)
                return 1;
            else
                return compare;
        }
    };
    Map<K, V> sortedByValues = new TreeMap<K, V>(valueComparator);
    sortedByValues.putAll(map);
    return sortedByValues;
}

[Buggy Hunk]
Map<K, V> sortedByValues = new TreeMap<K, V>(valueComparator);

[Patch]
Map<K, V> sortedByValues = new TreeMap<>(valueComparator);