[Demonstration 1]

[Buggy Method]
public static BufferedImage copyAspectScaled(BufferedImage img, int width, int height) {
    BufferedImage copy = new BufferedImage(width, height, img.getType());
    Graphics g = copy.getGraphics();
    g.setColor(Color.black);
    g.fillRect(0, 0, width, height);
    Size scaledSize = aspectScaledSize(img.getWidth(), img.getHeight(), width, height);
    Point offset = new Point((width - (int) scaledSize.width) / 2, (height - (int) scaledSize.height) / 2);
    g.drawImage(img, offset.x, offset.y, null);
    return copy;
}

[Buggy Hunk]
g.drawImage(img, offset.x, offset.y, null);

[Patch]
g.drawImage(img, offset.x, offset.y, (int)scaledSize.width, (int)scaledSize.height, null);

[Demonstration 2]

[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 3]

[Buggy Method]
public void send() {
    log.log(Level.INFO, "starting send()");
    // get the notification entry for this subject
    NotificationLog nl = ofy().load().type(NotificationLog.class).filter("subject", subject).first().now();
    if (nl != null) {
        log.log(Level.INFO, "Not notifying, last notification was {0}", Convutils.timeAgoToString(nl.getLastnotification().getMillis() / 1000L));
        return;
    }
    if (recipient == null || "".equals(recipient)) {
        recipient = DatastoreConfig.getValueForKey("admin");
    }
    log.log(Level.INFO, "no previous notification found, creating one");
    nl = new NotificationLog();
    nl.setLastnotification(Convutils.getNewDateTime());
    nl.setRecipient(recipient);
    nl.setSubject(subject);
    nl.setBody(body);
    ofy().save().entity(nl).now();
    alwaysSend();
}

[Buggy Hunk]
log.log(Level.INFO, "starting send()");

[Patch]
log.log(Level.INFO, "starting send({1})", subject);