[Demonstration 1]

[Buggy Method]
public static void main(String[] args) throws IOException {
    final ConsoleReader console;
    final SimpleLogger logger;
    final Router router;
    // Prepare and start
    synchronized (SYNC) {
        // Init console
        AnsiConsole.systemInstall();
        console = new ConsoleReader();
        console.setExpandEvents(false);
        logger = new SimpleLogger(console);
        System.setErr(new PrintStream(new LoggingOutputStream(logger, Level.SEVERE), true));
        System.setOut(new PrintStream(new LoggingOutputStream(logger, Level.INFO), true));
        router = new Router(console, logger);
        try {
            router.startAsync();
            router.awaitRunning(5, TimeUnit.SECONDS);
            if (router.state() == Service.State.FAILED) {
                throw router.failureCause();
            }
        } catch (Throwable t) {
            logger.log(Level.SEVERE, "Exception while starting!", t);
            if (router.state() == Service.State.FAILED) {
                logger.log(Level.SEVERE, "Service failed!", router.failureCause());
            }
            System.exit(ExitCode.EXCEPTION_STARTUP.code);
            return;
        }
    }
    ExitCode exitCode = ExitCode.NORMAL;
    // Process commands and shutdown
    try {
        // Process command input
        try {
            while (router.isRunning()) {
                final String line = console.readLine(">");
                if (line != null) {
                    router.getCommandManager().dispatchCommand(line);
                }
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Exception in main!", e);
            exitCode = ExitCode.EXCEPTION_COMMAND_PROCESS;
            System.exit(exitCode.code);
            return;
        }
        // Shutdown
        try {
            router.stopAsync();
            router.awaitTerminated(30, TimeUnit.SECONDS);
            if (router.state() == Service.State.FAILED) {
                throw router.failureCause();
            }
        } catch (Throwable t) {
            logger.log(Level.SEVERE, "Exception while shutdown!", t);
            exitCode = ExitCode.EXCEPTION_SHUTDOWN;
            System.exit(exitCode.code);
            return;
        }
    } finally {
        try {
            console.shutdown();
        } finally {
            try {
                logger.close();
            } finally {
                System.exit(exitCode.code);
            }
        }
    }
}

[Buggy Hunk]
if (router.state() == Service.State.FAILED) {

[Patch]
if(router.failureCause() != null || router.state() == Service.State.FAILED) {

[Demonstration 2]

[Buggy Method]
private void handle_ball_collisions() {
    //Ball.hold = true;
    int i = 0;
    for (Ball b : balls) {
        //goes through every ball except itself
        if (b != this) {
            //test for self
            if (near_by(b)) {
                if (collision(b)) {
                    if (b instanceof MainBall || this instanceof MainBall) {
                        //Lost game
                        Animation.game_active = false;
                        //removes all the balls
                        balls.clear();
                        // restarts the animation (potentially not necessary)
                        Driver.remove_animation();
                        Driver.create_animation();
                        return;
                        //Animation.game_active = false;
                        //return;
                    }
                    v.handle_ball_collision(b.v);
                    v.tick();
                    b.v.tick();
                    if (b.v.distance_to(v) > DIAMETER) {
                        //There wont be collision issues
                        v.undo();
                        b.v.undo();
                        return;
                    }
                    //There are collision issues:
                    /*
                going to take each ball and step them away from each other one
                vector step back at a time
              */
                    v.undo();
                    b.v.undo();
                    Vector temp_v = new Vector(v);
                    Vector temp_bv = new Vector(b.v);
                    //setting velocity to one step
                    v.set_velocity(1, 0);
                    if (v.x <= b.v.x) {
                        //swaps them based on position
                        v.set_velocity(-v.vx, 0);
                    }
                    b.v.set_velocity(-v.vx, 0);
                    //prevents an infinite loop
                    int saftey = 0;
                    //steps them away from each other until they're no longer collided
                    while (saftey < 30 && b.v.distance_to(v) <= DIAMETER) {
                        //update_velocity(0, 0, 2000, 1100);
                        v.tick();
                        if (b.v.distance_to(v) > DIAMETER)
                            break;
                        b.v.tick();
                        saftey++;
                    }
                    v.set_velocity(temp_v.vx, temp_v.vy);
                    b.v.set_velocity(temp_bv.vx, temp_bv.vy);
                    return;
                }
            }
        }
    }
}

[Buggy Hunk]
balls.clear(); //removes all the balls

[Patch]
Ball.balls.clear(); //removes all the balls;

[Demonstration 3]

[Buggy Method]
@Override
public void onFailure(Throwable caught) {
    log.log(Level.SEVERE, "deleteReport {0}", caught.getMessage());
}

[Buggy Hunk]
log.log(Level.SEVERE, "deleteReport {0}", caught.getMessage());

[Patch]
log.log(Level.SEVERE, "deleteReport {0}", caught);