[Demonstration 1]

[Buggy Method]
public boolean verify(String inpstr, String signature, PublicKey pubKey) {
    boolean verified = false;
    byte[] signedBytes = Base64.decode(signature);
    byte[] inpstrBytes = Base64.decode(inpstr);
    try {
        BouncyCastleProvider provider = new BouncyCastleProvider();
        Security.addProvider(provider);
        Signature verifier = Signature.getInstance("SHA1withRSA");
        verifier.initVerify(pubKey);
        verifier.update(inpstr.getBytes());
        if (verifier.verify(signedBytes)) {
            verified = true;
        } else {
            verified = false;
        }
    } catch (InvalidKeyException ex) {
        Logger.getLogger(X509Utils.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SignatureException ex) {
        Logger.getLogger(X509Utils.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchAlgorithmException ex) {
        Logger.getLogger(X509Utils.class.getName()).log(Level.SEVERE, null, ex);
    }
    return verified;
}

[Buggy Hunk]
public boolean verify(String inpstr, String signature, PublicKey pubKey) {

[Patch]
public static boolean verify(String inpstr, String signature, PublicKey pubKey) {

[Demonstration 2]

[Buggy Method]
public boolean isLeaseStillValid(int leaseId) {
    // 0 is not a valid id of a lease
    if (leaseId == 0) {
        return false;
    }
    // look up the lease in the database
    SynchronizationLease lease;
    try {
        lease = leaseDAO.getLease(leaseId);
    } catch (LeaseNotFoundException e) {
        // unknown lease is not valid
        return false;
    }
    long expirationTime = lease.getExpirationTime().getTime();
    long now = new Date().getTime();
    boolean valid = expirationTime < now;
    // if lease is invalid, delete it from the database
    if (!valid) {
        leaseDAO.deleteLease(lease);
    }
    return valid;
}

[Buggy Hunk]
boolean valid  = expirationTime < now;

[Patch]
boolean valid  = now < expirationTime;

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