[Demonstration 1]

[Buggy Method]
public void initialize() {
    // Get list of samples to include in the output
    // first get the sample for the RODs
    // Get list of samples to include in the output
    List<String> rodNames = Arrays.asList(variantCollection.variants.getName());
    Map<String, VCFHeader> vcfRods = GATKVCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames);
    TreeSet<String> vcfSamples = new TreeSet<>(SampleUtils.getSampleList(vcfRods, GATKVariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE));
    // get the samples for the files
    Collection<String> samplesFromFile = SampleUtils.getSamplesFromFiles(sampleFiles);
    // get the samples for the expression
    Collection<String> samplesFromExpressions = SampleUtils.matchSamplesExpressions(vcfSamples, sampleExpressions);
    // first, check overlap between requested and present samples
    Set<String> commandLineUniqueSamples = new HashSet<>(samplesFromFile.size() + samplesFromExpressions.size() + sampleNames.size());
    commandLineUniqueSamples.addAll(samplesFromFile);
    commandLineUniqueSamples.addAll(samplesFromExpressions);
    commandLineUniqueSamples.addAll(sampleNames);
    commandLineUniqueSamples.removeAll(vcfSamples);
    // second, add the requested samples
    samples.addAll(sampleNames);
    samples.addAll(samplesFromExpressions);
    samples.addAll(samplesFromFile);
    logger.debug(Utils.join(",", commandLineUniqueSamples));
    boolean noSamplesSpecified = false;
    // if none were requested, we want all of them
    if (samples.isEmpty()) {
        samples.addAll(vcfSamples);
        noSamplesSpecified = true;
    }
    // now, exclude any requested samples
    final Collection<String> XLsamplesFromFile = SampleUtils.getSamplesFromFiles(XLsampleFiles);
    final Collection<String> XLsamplesFromExpressions = SampleUtils.matchSamplesExpressions(vcfSamples, XLsampleExpressions);
    samples.removeAll(XLsamplesFromFile);
    samples.removeAll(XLsampleNames);
    samples.removeAll(XLsamplesFromExpressions);
    noSamplesSpecified = noSamplesSpecified && XLsampleNames.isEmpty() && XLsamplesFromFile.isEmpty() && XLsamplesFromExpressions.isEmpty();
    if (samples.isEmpty() && !noSamplesSpecified) {
        throw new UserException("All samples requested to be included were also requested to be excluded.");
    }
    // log the samples included and generate the samples for the writer
    HashSet<String> outputSamples = new HashSet<>(samples.size() * 2);
    for (String sample : samples) {
        if (!noSamplesSpecified) {
            logger.info("Including sample '" + sample + "'");
        }
        outputSamples.add(getSampleChromosomeName(sample, 1));
        outputSamples.add(getSampleChromosomeName(sample, 1));
    }
    // Initialize VCF header
    Set<VCFHeaderLine> headerLines = VCFUtils.smartMergeHeaders(vcfRods.values(), true);
    headerLines.add(new VCFHeaderLine("source", this.getClass().getSimpleName()));
    // write the header with the output samples
    writer.writeHeader(new VCFHeader(headerLines, outputSamples));
    // set the randomizer
    randomizer = new Random(seed);
}

[Buggy Hunk]
outputSamples.add(getSampleChromosomeName(sample, 1));

[Patch]
outputSamples.add(getSampleChromosomeName(sample, 2));

[Demonstration 2]

[Buggy Method]
ArrayList<Project> getProjects() {
    ArrayList<Project> projects = new ArrayList<>();
    Cursor cursor = db.rawQuery("SELECT * FROM projects WHERE done = 0", null);
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        projects.add(getProjectFromCursor(cursor));
        cursor.moveToNext();
    }
    cursor.close();
    return projects;
}

[Buggy Hunk]
projects.add(getProjectFromCursor(cursor));

[Patch]
projects.add(getProjectFromCursor(cursor, false));

[Demonstration 3]

[Buggy Method]
private static String[] getJarPaths(String jarPath) throws IOException {
    return Files.walk(Paths.get(jarPath)).map(Path::toString).filter(path -> path.endsWith(".jar")).map(path -> new File(path).getAbsolutePath()).toArray(String[]::new);
}

[Buggy Hunk]
private static String[] getJarPaths(String jarPath) throws IOException {

[Patch]
private String[] getJarPaths(String jarPath) throws IOException {