[Demonstration 1]

[Buggy Method]
public void start() {
    logger.info("Initialise file parser {} ...", number.incrementAndGet());
    try {
        while (lock.get()) {
            final Path file = directoryQueue.take();
            logger.debug("<-- take file \'{}\' : directoryQueue", file.getFileName());
            if (isReadyToParse(file)) {
                parse(file);
                continue;
            }
            final String description = String.format("exists: %s; symlink loop: %s; readable: %s; file: %s", Files.exists(file), SymlinkLoops.isSymbolicLinkLoop(file), Files.isReadable(file), Files.isRegularFile(file));
            notProcessed(file, description);
        }
    } catch (Exception e) {
        logger.error("Error in file parser", e);
    } finally {
        serverLock.compareAndSet(true, false);
    }
}

[Buggy Hunk]
logger.debug("<-- take file \'{}\' : directoryQueue", file.getFileName());

[Patch]
logger.info("<-- take file \'{}\' : directoryQueue", file.getFileName());

[Demonstration 2]

[Buggy Method]
@Override
public byte evaluate(final ArduinoRecord the_record) {
    if (the_record == null || the_record.getData() != null) {
        final ArduinoData data = the_record.getData();
        my_stats.update(data);
        if (data.moisture() != ArduinoData.NO_MOISTURE_DATA) {
            if (data.moisture() < my_low_moisture) {
                my_relays.setRelay(my_water, true);
            } else if (data.moisture() > my_nominal_moisture && data.moisture() < my_high_moisture) {
                my_relays.setRelay(my_water, false);
            } else {
                LOG.error(String.format("HIGH soil moisture level %d", data.moisture()));
            }
        }
        if (data.temperature() != ArduinoData.NO_TEMPERATURE_DATA) {
            if (data.temperature() < my_low_temp) {
                LOG.error(String.format("LOW temperature %d", data.temperature()));
                my_relays.setRelay(my_fan, false);
            } else if (data.temperature() > my_nominal_temp) {
                my_relays.setRelay(my_fan, true);
            } else if (data.temperature() > my_high_temp) {
                LOG.error(String.format("CRITICAL temperature : %d", data.temperature()));
            }
        }
        final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"));
        final int time = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE);
        final boolean light_sched_on = time >= my_on_time && time > my_off_time;
        final boolean light_commanded_on = my_relays.getRelayState(my_light);
        if (light_sched_on && !light_commanded_on) {
            my_relays.setRelay(my_light, light_sched_on);
            my_relays.setRelay(my_air_circ, true);
        } else if (!light_sched_on) {
            //TODO hard coded cycle fan every 5 minutes if light off.
            if (time % 10 < 5) {
                my_relays.setRelay(my_air_circ, !my_relays.getRelayState(my_air_circ));
            }
        }
        if (data.lightData() != null) {
            final boolean light_on_actual = data.lightData().getValue(MODE.FULL) > 0;
            if (light_on_actual != light_sched_on) {
                LOG.error(String.format("WARNING light commanded %s but %light was detected.", (light_commanded_on ? "ON" : "OFF"), (light_on_actual ? "NO " : "")));
            }
        }
    }
    LOG.debug("Evaluated reading from Arduino");
    LOG.debug("STATS:");
    LOG.debug(my_stats);
    LOG.debug("RELAYS");
    LOG.debug(my_relays.getState());
    return my_relays.getState();
}

[Buggy Hunk]
LOG.error(String.format("WARNING light commanded %s but %light was detected.", (light_commanded_on ? "ON" : "OFF"), (light_on_actual ? "NO " : "")));

[Patch]
LOG.error(String.format("WARNING light on = %b detected %d lux.", light_commanded_on, data.lightData().getValue(MODE.LUX)));

[Demonstration 3]

[Buggy Method]
public static synchronized void writeFile(String fileName, byte[] data) {
    Path file = Paths.get(fileName);
    try {
        if (Files.exists(file)) {
            Files.write(file, data, StandardOpenOption.APPEND);
        } else {
            Files.write(file, data);
        }
    } catch (NoSuchFileException e) {
        try {
            Files.write(file, data);
        } catch (IOException e1) {
            logger.error("Error :", e);
        }
    } catch (IOException e) {
        logger.error("File writing error", e);
    }
}

[Buggy Hunk]
Files.write(file, data, StandardOpenOption.APPEND);

[Patch]
Files.write(file, data, StandardOpenOption.WRITE);