[Demonstration 1]

[Buggy Method]
public <T> T process(ThriftProtocolSupportIF<T> tps, ThriftClient thriftClient) throws TException {
    try {
        stat();
        final TMessage msg = tps.getTMessage();
        final LogEntry logEntry = new LogEntry(msg.name);
        logEntry.seqId = msg.seqid;
        final ThriftControllerInfo controllerInfo = registry.getController(msg.name);
        if (controllerInfo == null) {
            tps.skip();
            logNoController(thriftClient, msg.name, tps.getSessionId());
            return tps.result(new TApplicationException(TApplicationException.UNKNOWN_METHOD, "No controllerCls for method " + msg.name), null);
        }
        final TBase args;
        try {
            args = tps.readArgs(controllerInfo);
        } catch (Exception e) {
            return tps.result(e, controllerInfo);
        }
        final Logger log = LoggerFactory.getLogger(controllerInfo.getControllerCls());
        logStart(log, thriftClient, msg.name, tps.getSessionId(), args);
        final ThriftController controller = controllerInfo.makeController(args, tps, logEntry, msg.seqid, thriftClient, registry.getType(), tps.allowAsyncAnswer());
        try {
            final Object ret = controller.handle(args);
            try {
                return tps.result(ret, controllerInfo);
            } finally {
                logEnd(log, controller, msg.name, tps.getSessionId(), ret);
            }
        } catch (AsyncAnswer e) {
            return null;
        } catch (Exception e) {
            log.error("Exception while handle thrift request", e);
            try {
                return tps.result(e, controllerInfo);
            } finally {
                logEnd(log, controller, msg.name, tps.getSessionId(), null);
            }
        }
    } catch (RuntimeException e) {
        log.error("Exception while serving thrift request", e);
        throw e;
    }
}

[Buggy Hunk]
logEnd(log, controller, msg.name, tps.getSessionId(), null);

[Patch]
logEnd(log, controller, msg.name, tps.getSessionId(), e);

[Demonstration 2]

[Buggy Method]
static OVar createString(String inp) {
    //System.err.println("***\nFIX THIS\n***");
    System.out.println("[MakeString] Handed '" + inp + "'");
    String asmName = level.peek().asmName + ".string_" + level.peek().stringLevel++;
    String type = "String";
    String name = inp.trim();
    String dat_asmName = asmName + "_data";
    String dat_type = "byte";
    String dat_name = dat_asmName + "@INVALID:STR_REF";
    OVar dat = new OPrimitive(dat_type, new String[0], dat_asmName);
    dat.ival = inp + ", 0";
    level.peek().vars.put(dat_name, dat);
    OVar var = new OVar(type, new String[0], asmName);
    var.ival = dat_asmName;
    level.peek().vars.put(name, var);
    return var;
}

[Buggy Hunk]
String name = inp.trim();

[Patch]
String name = inp.trim() + strindexctr++ + "@INVALID:STR_REF";

[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));