[Demonstration 1]

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

[Demonstration 2]

[Buggy Method]
public Class<?> genFuncCode(String className, boolean writeFile) {
    try {
        ExprClassLoader mcl = new ExprClassLoader(CodeGenerator.class.getClassLoader());
        CodeGenerator cgen = new CodeGenerator();
        cgen.startClass(className, null);
        // Define method
        int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC;
        Type[] paramTypes = getAndFixParameterTypes();
        Type retType = this.getRetType();
        cgen.startMethod(access, name, Type.getMethodDescriptor(retType, paramTypes));
        MethodVisitor mv = cgen.getMV();
        MethodGenHelper mg = new MethodGenHelper(mv, paramVarMap);
        mg.updateLVTIndex(true);
        cgen.startCode();
        // Generate code for all the expressions
        for (int i = 0; i < this.body.size(); i++) {
            ExprNode expr = this.body.get(i);
            expr.genCode(mg);
        }
        mg.visitInsn(retType.getOpcode(Opcodes.IRETURN));
        for (VariableNode var : paramVarMap.values()) {
            mg.visitLocalVariable(var.name, var.getType().getDescriptor(), null, cgen.labelStart, cgen.lableEnd, var.idxLVT);
        }
        // Auto generated
        mg.visitMaxs(-1, -1);
        cgen.endCode();
        cgen.endClass();
        byte[] bcode = cgen.dump();
        if (writeFile) {
            FileOutputStream fos = new FileOutputStream(className + ".class");
            fos.write(bcode);
            fos.close();
        }
        Class<?> c = mcl.defineClassForName(null, bcode);
        return c;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

[Buggy Hunk]
for (int i = 0; i < this.body.size(); i++) {

[Patch]
for (int i = this.body.size()-1; i >= 0; i--) {

[Demonstration 3]

[Buggy Method]
@Override
public List<IBook> listBooks() {
    List<IBook> list = (List<IBook>) this.bookMap.values();
    return list;
}

[Buggy Hunk]
List<IBook> list = (List<IBook>) this.bookMap.values();

[Patch]
List<IBook> list = new ArrayList<IBook>(this.bookMap.values());