[Demonstration 1]

[Buggy Method]
@RequestMapping(value = "/ihe/documents", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
public List<Document> getIHEDocuments(@RequestParam(value = "patientId", required = true) String patientId) throws IOException {
    Resource documentsFile = resourceLoader.getResource("classpath:" + IHE_DOCUMENTS_FILE_NAME);
    //load all patients from the file
    BufferedReader reader = null;
    CSVParser parser = null;
    try {
        reader = new BufferedReader(new InputStreamReader(documentsFile.getInputStream()));
        parser = new CSVParser(reader, CSVFormat.EXCEL);
        List<CSVRecord> records = parser.getRecords();
        if (records.size() <= 1) {
            throw new IOException("The file appears to have a header line with no other information. Please make sure there are at least two rows in the CSV file.");
        }
        List<Document> docsForPatient = new ArrayList<Document>();
        for (CSVRecord record : records) {
            String colValue = record.get(0).toString().trim();
            if (!StringUtils.isEmpty(colValue) && !"ID".equals(colValue)) {
                String docPatientId = record.get(1).toString().trim();
                if (!StringUtils.isEmpty(docPatientId) && docPatientId.equals(patientId)) {
                    Document document = new Document();
                    document.setId(colValue);
                    document.setName(record.get(2).toString().trim());
                    Patient patient = new Patient();
                    patient.setId(docPatientId);
                    document.setPatient(patient);
                    docsForPatient.add(document);
                }
            }
        }
        return docsForPatient;
    } catch (IOException ioEx) {
        logger.error("Could not get input stream for uploaded file " + IHE_DOCUMENTS_FILE_NAME);
        throw new IOException("Could not get input stream for file " + IHE_DOCUMENTS_FILE_NAME);
    } finally {
        try {
            parser.close();
        } catch (Exception ignore) {
        }
        try {
            reader.close();
        } catch (Exception ignore) {
        }
    }
}

[Buggy Hunk]
patient.setId(docPatientId);

[Patch]
patient.setOrgPatientId(docPatientId);

[Demonstration 2]

[Buggy Method]
public String toString() {
    return String.format("Link(id1=%d, id2=%d, link_type=%d," + "visibility=%d, version=%d," + "time=%d, data=%s", id1, id2, link_type, visibility, version, time, data.toString());
}

[Buggy Hunk]
visibility, version, time, data.toString());

[Patch]
visibility, version, time, Arrays.toString(data));

[Demonstration 3]

[Buggy Method]
public SyndFeed buildFeed(InputStream is) throws IllegalArgumentException, FeedException {
    SyndFeedInput input = new SyndFeedInput();
    Reader reader = new InputStreamReader(is);
    SyndFeed feed = input.build(reader);
    return feed;
}

[Buggy Hunk]
Reader reader = new InputStreamReader(is);

[Patch]
InputSource  reader = new InputSource(is);