[Demonstration 1]

[Buggy Method]
@Test
public void testCancel() {
    ExecutorService executor = Executors.newCachedThreadPool();
    Future<RawImage> future = executor.submit(() -> getRawImage("Cat", 8000));
    assertFalse(future.isDone());
    assertFalse(future.isCancelled());
    delay(4000);
    System.out.println("Cancelling task...");
    future.cancel(false);
    assertTrue(future.isDone());
    assertTrue(future.isCancelled());
    System.out.println("Done");
    delay(6000);
}

[Buggy Hunk]
future.cancel(false);

[Patch]
future.cancel(true);

[Demonstration 2]

[Buggy Method]
private static Action getAddServerAction(final Node parent) {
    Action act = new Action(Permission.READ, new Handler<ActionResult>() {

        @Override
        public void handle(ActionResult event) {
            JsonObject params = event.getJsonIn().getObject("params");
            if (params == null) {
                throw new IllegalArgumentException("params");
            }
            String name = params.getString("name");
            String url = params.getString("url");
            String username = params.getString("username");
            String password = params.getString("password");
            if (name == null) {
                throw new IllegalArgumentException("name");
            } else if (url == null) {
                throw new IllegalArgumentException("url");
            } else if (username == null) {
                throw new IllegalArgumentException("username");
            } else if (password == null) {
                throw new IllegalArgumentException("password");
            }
            NodeBuilder builder = parent.createChild(name);
            builder.setConfig("url", new Value(url));
            builder.setConfig("username", new Value(username));
            builder.setPassword(password.toCharArray());
            Node node = builder.build();
            Haystack haystack = new Haystack(node);
            node.getListener().addOnListHandler(getRootListHandler(haystack));
            builder = node.createChild("connect");
            builder.setAction(getConnectAction(haystack));
            builder.build();
            haystack.connect();
        }
    });
    act.addParameter(new Parameter("name", ValueType.STRING));
    act.addParameter(new Parameter("url", ValueType.STRING));
    act.addParameter(new Parameter("username", ValueType.STRING));
    act.addParameter(new Parameter("password", ValueType.STRING));
    return act;
}

[Buggy Hunk]
node.getListener().addOnListHandler(getRootListHandler(haystack));

[Patch]
node.getListener().addOnListHandler(haystack.getNavHandler(null));

[Demonstration 3]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));