[Demonstration 1]

[Buggy Method]
public static void updateFitness(ArrayList<Prisoner> pool, boolean recordComm) {
    int iterations = (int) (Settings.FIGHT_PERCENTAGE * pool.size());
    if (recordComm) {
        commData = new ArrayList<ArrayList<Double>>();
        for (int i = 0; i < iterations; i++) commData.add(new ArrayList<Double>());
    }
    ArrayList<Integer> scores = new ArrayList<Integer>();
    ArrayList<Integer> plays = new ArrayList<Integer>();
    for (int i = 0; i < pool.size(); i++) {
        scores.add(new Integer(0));
        plays.add(new Integer(0));
    }
    for (int i = 0; i < pool.size(); i++) {
        for (int j = 0; j < iterations; j++) {
            Prisoner p2 = pool.get((int) (Math.random() * pool.size()));
            ArrayList<Integer> matchResult = runMatch(pool.get(i), p2, recordComm);
            scores.set(i, new Integer(scores.get(i).intValue() + matchResult.get(0)));
            scores.set(j, new Integer(scores.get(j).intValue() + matchResult.get(1)));
            plays.set(i, new Integer(plays.get(i).intValue() + 1));
            plays.set(j, new Integer(plays.get(j).intValue() + 1));
        }
    }
    for (int i = 0; i < pool.size(); i++) {
        pool.get(i).setFitness(((double) scores.get(i)) / plays.get(i));
    }
}

[Buggy Hunk]
for(int i=0; i<iterations; i++) commData.add(new ArrayList<Double>());

[Patch]
for(int i=0; i<Settings.THINKING_STEPS; i++) commData.add(new ArrayList<Double>());

[Demonstration 2]

[Buggy Method]
@Override
public boolean executeQuery(String query) {
    columns.clear();
    rows.clear();
    try (Connection conn = DriverManager.getConnection(getConnString(), properties);
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(query)) {
        ResultSetMetaData rmd = rs.getMetaData();
        int size = rmd.getColumnCount();
        for (int i = 0; i < size; i++) getColumns().add(rmd.getColumnLabel(i + 1));
        while (rs.next()) {
            Row row = new Row();
            for (int i = 0; i < size; i++) row.setData(i, rs.getString(i + 1));
            rows.add(row);
        }
    } catch (SQLException e) {
        errorMessage = e.getMessage();
        errorCode = e.getErrorCode();
        return false;
    }
    return true;
}

[Buggy Hunk]
getColumns().add(rmd.getColumnLabel(i + 1));

[Patch]
columns.add(rmd.getColumnLabel(i + 1));

[Demonstration 3]

[Buggy Method]
public void configure() {
    Namespaces ns = new Namespaces("soap", "http://schemas.xmlsoap.org/soap/envelope/");
    onException(Throwable.class, Exception.class, NullPointerException.class).to("log:gov.nih.nci.cabig.caaers2adeers.general_error?showHeaders=true&multiline=true&level=ERROR").choice().when(header(ToCaaersReportWSRouteBuilder.NEEDS_ACK).isEqualTo(Boolean.TRUE.toString())).to("xslt:" + ToCaaersReportWSRouteBuilder.responseXSLBase + "E2BParserErrors2ACK.xsl").to("direct:sendE2BAckSink").otherwise().to("direct:morgue").stop().end();
    onException(ClassCastException.class).// create a custom failure response
    to("log:gov.nih.nci.cabig.caaers2adeers.class_cast_error?showHeaders=true&multiline=true&level=ERROR").choice().when(header(ToCaaersReportWSRouteBuilder.NEEDS_ACK).isEqualTo(Boolean.TRUE.toString())).to("xslt:" + ToCaaersReportWSRouteBuilder.responseXSLBase + "E2BParserErrors2ACK.xsl").to("direct:sendE2BAckSink").otherwise().//todo; this generates the referencenumber on startup and it is not modified afterward.
    transform(constant("<Response ReferenceNumber=\"" + System.currentTimeMillis() + "\" IsTransactionSuccessful=\"0\" " + "ReasonCode=\"WS_GEN_007\" ErrorClientResponseMessage=\"Invalid XML\"/>")).// remember not to set as handled(true) to make camel think it's OK response,
    // this error would be caught in the binding component, which will determine correct response
    setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)).process(track(REQUST_PROCESSING_ERROR, "Error")).to(fileTracker.fileURI(REQUST_PROCESSING_ERROR)).stop().end();
    // route for caaers integration services - trim white space
    from("jetty:http://0.0.0.0:7711/caaers/services/RaveIntegrationServices").streamCaching().choice().when(header("CamelHttpMethod").isEqualTo("POST")).setExchangePattern(ExchangePattern.InOut).processRef("crlfFixProcessor").processRef("raveIntegrationHeaderProcessor").processRef("headerGeneratorProcessor").process(track(REQUEST_RECEIVED)).to(fileTracker.fileURI(REQUEST_RECEIVED)).choice().when(header(INVALID_MESSAGE).isEqualTo("true")).to("direct:soapfault").otherwise().doTry().to("validator:xsd/soap-envelope.xsd").process(track(PRE_PROCESS_RAVE_INTEGRATION_MSG)).to(fileTracker.fileURI(PRE_PROCESS_RAVE_INTEGRATION_MSG)).to("direct:processedRave2CaaersMessageSink").doCatch(SAXParseException.class).to("direct:soapfault").stop().end();
    //configure route towards caAERS Webservices
    fromRaveToCaaersWSRouteBuilder.configure(this);
    //check for errors
    from("direct:rave2CaaersOutSink").to("log:gov.nih.nci.cabig.rave2caaers.from-rave2CaaersOutSink?showAll=true&level=TRACE&showException=true&showStackTrace=true").process(track(REQUEST_COMPLETION)).to(fileTracker.fileURI(REQUEST_COMPLETION));
    // route for Participant Service
    from("jetty:http://0.0.0.0:7700/caaers/ParticipantInitialization?httpBindingRef=participantODMMessageBinding").streamCaching().choice().when(header("CamelHttpMethod").isEqualTo("POST")).process(track(REQUEST_RECEIVED)).processRef("participantODMMessageProcessor").processRef("crlfFixProcessor").processRef("headerGeneratorProcessor").to(fileTracker.fileURI(REQUEST_RECEIVED)).to("xslt:" + "xslt/caaers/request/strip_namespaces.xsl").process(track(PRE_PROCESS_OPEN_ODM_MSG)).to("direct:processedOpenOdmMessageSink").otherwise().end();
    //configure route towards caAERS Webservices
    toCaaersParticipantWSRouteBuilder.configure(this);
    //check for errors
    from("direct:odmOutSink").to("log:gov.nih.nci.cabig.open2caaers.from-oDMoutputSink?showAll=true&level=TRACE&showException=true&showStackTrace=true").process(track(REQUEST_COMPLETION)).to(fileTracker.fileURI(REQUEST_COMPLETION));
    //just for testing generic webservice
    from("jbi:service:http://schema.integration.caaers.cabig.nci.nih.gov/common/generic-processor-sink").processRef("exchangePreProcessor").processRef("headerGeneratorProcessor").process(track(REQUEST_RECEIVED)).to(fileTracker.fileURI(REQUEST_RECEIVED)).to("xslt:xslt/adeers/request/soap_env_filter.xsl").process(track(ROUTED_TO_ADEERS_REQUEST_SINK)).to("direct:adEERSRequestSink");
    //configure all the Quartz cron jobs
    cronJobRouteBuilder.configure(this);
    //configure routes towards adeers
    toAdeersRouteBuilder.configure(this);
    //configure route towards caAERS Webservices
    toCaaersWebserviceRouteBuilder.configure(this);
    //configure routes towards caAERS client
    toCaaersClientRouteBuilder.configure(this);
    //configure routes towards caAERS safety report service with E2B input
    toCaaersReportWSRouteBuilder.configure(this);
    //process adeers response and generate E2B ACK
    adeersResponseToE2BAckRouteBuilder.configure(this);
    //
    //for report submission to adeers
    adeersReportServiceRouteBuilder.configure(this);
    //need to process AdEERS results, may be the SyncComponent...
    from("direct:adEERSResponseSink").to("log:gov.nih.nci.cabig.caaers2adeers.synch-comp?showHeaders=true&level=TRACE&showException=true&showStackTrace=true").choice().when().xpath("//operation/errors/error").to("direct:morgue").when().xpath("not(//operation/data/child::*/child::*)").process(track(NO_DATA_AVAILABLE, "Processed")).to("direct:outputSink").when(header("c2a_sync_mode").isEqualTo("async")).process(track(ROUTED_TO_CAAERS_REQUEST_SINK)).to("direct:caaersWSRequestSink").otherwise().process(track(ROUTED_TO_CAAERS_REQUEST_SINK)).to("direct:caaersClientRequestSink");
    //need to process caAERS results
    from("direct:caAERSResponseSink").choice().when().xpath("//operation/errors/error").to("direct:morgue").when().xpath("//soap:Fault", ns).to("direct:morgue").otherwise().to("direct:outputSink");
    //BELOW 3 routes are the final sinks of messages.
    from("direct:outputSink").to("log:gov.nih.nci.cabig.caaers2adeers.from-outputSink?showAll=true&level=TRACE&showException=true&showStackTrace=true").process(track(REQUEST_COMPLETION)).to(fileTracker.fileURI(REQUEST_COMPLETION));
    //invalid requests
    from("direct:morgue").to("log:gov.nih.nci.cabig.caaers2adeers.invalid?showAll=true&level=WARN&showException=true&showStackTrace=true").process(track(REQUST_PROCESSING_ERROR, "Error")).to("xslt:xslt/caaers/response/unknown.xsl").to(fileTracker.fileURI(REQUST_PROCESSING_ERROR));
    //invalid soap requests
    from("direct:soapfault").to("log:gov.nih.nci.cabig.caaers2adeers.invalidsoap?showAll=true&level=WARN&showException=true&showStackTrace=true").transform(constant("<error>Invalid Soap Request</error>")).to("xslt:xslt/caaers/response/soapfault.xsl").process(track(REQUST_PROCESSING_ERROR, "Invalid SOAP request")).to(fileTracker.fileURI(REQUST_PROCESSING_ERROR));
}

[Buggy Hunk]
.to("xslt:" + ToCaaersReportWSRouteBuilder.responseXSLBase + "E2BParserErrors2ACK.xsl")

[Patch]
.processRef("errorParserProcessor")