[Demonstration 1]

[Buggy Method]
public boolean addUserToCluster(long userId, long clusterId) {
    User user = userService.getActiveUser(userId);
    Cluster cluster = getCluster(clusterId);
    if (user == null || cluster == null || cluster.userExists(user)) {
        return false;
    }
    user.setCurrentClusterId(clusterId);
    return cluster.addUser(user);
}

[Buggy Hunk]
if (user == null || cluster == null || cluster.userExists(user)) {

[Patch]
if (user == null || cluster == null || cluster.userExists(user) || user.getCurrentClusterId() != -1) {

[Demonstration 2]

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

[Buggy Method]
private static String replaceSpecials() {
    // http://utf8-chartable.de/unicode-utf8-table.pl?start=8064&names=-&utf8=0x
    String pageSource = "";
    pageSource = driver.getPageSource();
    byte[] allBytes = null;
    try {
        allBytes = pageSource.getBytes("UTF-8");
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    }
    String translate = "";
    for (int i = 0; i < allBytes.length; i++) {
        // newBytes[i + offset] = allBytes[i];
        if (allBytes[i] == ((byte) 0xE2)) {
            // System.out.println(String.format("0xE2%s%s " , toHexStr(allBytes[i +
            // 1]), " " + toHexStr(allBytes[i + 2])));
            switch(allBytes[i + 2]) {
                // opening single quote
                case (byte) 0x98:
                case // closing single quote
                (byte) 0x99:
                    translate += "'";
                    i += 2;
                    break;
                case // dash, also 0xe292, 0xe293
                (byte) 0x94:
                    translate += "-";
                    i += 2;
                    break;
                // opening double quote
                case (byte) 0x9c:
                case // closing double quote
                (byte) 0x9d:
                    translate += "\"";
                    i += 2;
                    break;
            }
        } else {
            translate += (char) allBytes[i];
        }
    }
    // pageSource = translate;
    return translate;
}

[Buggy Hunk]
private static String replaceSpecials() {

[Patch]
private String replaceSpecials() {