[Demonstration 1]

[Buggy Method]
@Override
protected void execute(WgmfGameParams params) {
    String[] splitted = DATAPROFILE_TEMPLATE.split("/");
    OptiFlexCsvResultWriter.writeCsvFile(resultFileName, Collections.emptyList(), false);
    final int agents = getnAgents();
    logger.info("Creating tasks objects.");
    //Create tasks
    List<GenericTask<OptaExperimentResults>> executables = Lists.newArrayList();
    ListMultimap<HourlyFlexConstraints, GenericTask<OptaExperimentResults>> experiments = LinkedListMultimap.create();
    for (int ia = 1; ia < 12; ia++) {
        for (int dur = 1; dur <= 8; dur *= 2) {
            HourlyFlexConstraints constraints = HourlyFlexConstraints.builder().activationDuration(dur).interActivationTime(ia).maximumActivations(FLEX_BASE / dur).build();
            long seed = 1234;
            for (int rep = 0; rep < getnReps(); rep++) {
                OptaJppfTask optaJppfTask = new OptaJppfTask(params, seed + rep, agents, constraints);
                executables.add(optaJppfTask);
                experiments.put(constraints, optaJppfTask);
            }
        }
    }
    logger.info("Starting experiment execution");
    //Execution
    ListMultimap<HourlyFlexConstraints, BigDecimal> experimentResults = LinkedListMultimap.create();
    ExperimentRunner runner = getStrategy().getRunner(params, this.PARAM_KEY, "OptiFlex job.");
    List<GenericTask<OptaExperimentResults>> adaptedExecutables = getStrategy().adapt(executables, this.PARAMS_KEY);
    runner.runExperiments(adaptedExecutables);
    List<?> resultObjects = runner.waitAndGetResults();
    getStrategy().processExecutionResultsLogErrorsOnly(resultObjects, (obj) -> experimentResults.put(((OptaExperimentResults) obj).getFlexConstraints(), ((OptaExperimentResults) obj).getResultValue()));
    logger.info("Parsing experiment results.");
    //Parse results
    Map<HourlyFlexConstraints, ConfidenceInterval> results = Maps.newLinkedHashMap();
    for (HourlyFlexConstraints f : experiments.keySet()) {
        List<Double> dres = experimentResults.get(f).stream().mapToDouble(BigDecimal::doubleValue).boxed().collect(Collectors.toList());
        StatAccumulator sa = new StatAccumulator();
        dres.forEach(sa::accept);
        ConfidenceInterval ci = sa.getCI(ConfidenceLevel._95pc);
        results.put(f, ci);
        OptiFlexCsvResultWriter.OptiFlexResults optiFlexResults = OptiFlexCsvResultWriter.OptiFlexResults.create(getnAgents(), getnReps(), splitted[splitted.length - 1].replace("*", String.valueOf("[" + dataProfileIdx + "]")), f.getActivationDuration(), f.getInterActivationTime(), (int) f.getMaximumActivations(), CI_LEVEL.getConfidenceLevel(), ci, windErrorFileIdx);
        writableResults.add(optiFlexResults);
    }
    OptiFlexCsvResultWriter.writeCsvFile(resultFileName, writableResults, true);
}

[Buggy Hunk]
for (int dur = 1; dur <= 8; dur *= 2) {

[Patch]
for (double dur = 1; dur <= 8; dur *= 2) {

[Demonstration 2]

[Buggy Method]
public String getFileContent(String dirName, String fileName) {
    File dir = new File(OjConfig.getString("workPath"), dirName);
    File file = new File(dir, fileName);
    String content;
    try {
        content = FileUtils.readFileToString(file);
    } catch (IOException e) {
        content = e.getMessage();
        log.error("cannot read file!", e);
    }
    return content;
}

[Buggy Hunk]
content = FileUtils.readFileToString(file);

[Patch]
content = FileUtils.readFileToString(file, "UTF-8");

[Demonstration 3]

[Buggy Method]
public UniformAPILogEntry parseEvent(String line) throws Exception {
    try {
        String[] splits = line.substring(0, line.lastIndexOf(" - ")).split(":");
        String hostName = splits[1].trim();
        Integer statusCode = Integer.parseInt(splits[2]);
        Integer responseSizeInBytes = !splits[3].equals("-") ? Integer.parseInt(splits[3]) : null;
        Float processingTime = !splits[4].equals("-") ? Float.parseFloat(splits[4]) : null;
        String ip = !splits[5].equals("-") ? splits[5] : null;
        String requestString = !splits[6].equals("-") ? splits[6] : null;
        String applicationInfo = !splits[7].equals("-") ? splits[7] : null;
        String deviceId = !splits[8].equals("-") ? splits[8] : null;
        String countryCode = !splits[9].equals("-") ? splits[9] : null;
        String languageCode = !splits[10].equals("-") ? splits[10] : null;
        String platform = !splits[11].equals("-") ? splits[11] : null;
        Integer version = !splits[12].equals("-") ? Integer.parseInt(splits[12]) : null;
        String datePart = line.substring(line.lastIndexOf("[") + 1, line.lastIndexOf("]"));
        LOG.debug("datePart = " + datePart);
        Long timeStamp = apiTimeFormat.parse(datePart).getTime();
        String reqType = line.substring(line.lastIndexOf("- ")).split(" ")[1];
        UniformAPILogEntry logEntry = new UniformAPILogEntry(reqType);
        logEntry.setHostName(hostName);
        logEntry.setStatusCode(statusCode);
        logEntry.setResponseSizeInBytes(responseSizeInBytes);
        logEntry.setProcessingTime(processingTime);
        logEntry.setIp(ip);
        logEntry.setRequestString(requestString);
        logEntry.setApplicationInfo(applicationInfo);
        logEntry.setDeviceId(deviceId);
        logEntry.setCountryCode(countryCode);
        logEntry.setLanguageCode(languageCode);
        logEntry.setPlatform(platform);
        logEntry.setAppVersion(version);
        logEntry.setRequestTime(timeStamp);
        return logEntry;
    } catch (Exception e) {
        LOG.error("Error in parser", e);
        throw new Exception(e);
    }
}

[Buggy Hunk]
LOG.error("Error in parser", e);

[Patch]
LOG.error("Error in parser, line = " + line, e);