[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]
private List<Integer[]> optimize(List<String> values) {
    if (CollectionUtils.size(values) <= 1) {
        Collections.emptyList();
    }
    List<Integer[]> retList = new ArrayList<Integer[]>();
    Integer minValue = null;
    Integer maxValue = null;
    Integer intValue = null;
    Integer preValue = null;
    // create integer list
    List<Integer> subValues = new ArrayList<Integer>(values.size());
    try {
        for (String value : values) {
            subValues.add(Integer.parseInt(value));
        }
        Collections.sort(subValues);
    } catch (NumberFormatException e) {
        log.info("NumberFormatException intValue=" + intValue, e);
        return Collections.emptyList();
    }
    int index = 0;
    while (index < subValues.size()) {
        intValue = subValues.get(index);
        if (index == 0) {
            minValue = intValue;
            maxValue = minValue;
        } else {
            // equals
            if (preValue.intValue() == intValue.intValue()) {
                maxValue = preValue;
            } else if (preValue + 1 != intValue.intValue()) {
                // add another between clause
                retList.add(new Integer[] { minValue, preValue });
                minValue = intValue;
                maxValue = intValue;
            } else {
                maxValue = preValue + 1;
            }
        }
        preValue = intValue;
        index++;
    }
    // add between clause
    retList.add(new Integer[] { minValue, maxValue });
    // if the optimized parameters is
    if (retList.size() * 2 < values.size()) {
        return retList;
    } else {
        return Collections.emptyList();
    }
}

[Buggy Hunk]
log.info("NumberFormatException intValue=" + intValue, e);

[Patch]
log.debug(intValue + " cannot be converted to a number");

[Demonstration 3]

[Buggy Method]
private int getMedianValueAtIndex(int[] a, int index, int radius, int valueToIgnore) {
    int minIndex = Math.max(0, index - radius);
    int maxIndex = Math.min(a.length - 1, index + radius);
    int span = (maxIndex - minIndex) + 1;
    int[] temp = new int[span];
    ArrayList<Integer> v = new ArrayList<Integer>();
    System.arraycopy(a, minIndex, temp, 0, span);
    Arrays.sort(temp);
    for (int i = 0; i < span; i++) {
        if (temp[i] != valueToIgnore) {
            v.add(temp[i]);
        }
    }
    int size = v.size();
    if (size == 1) {
        return (v.get(0));
    } else if (size % 2 == 1) {
        return (v.get((size - 1) / 2));
    } else if (size != 0) {
        return (int) ((v.get(size / 2) + v.get((size / 2) - 1)) / 2);
    } else {
        return valueToIgnore;
    }
}

[Buggy Hunk]
ArrayList<Integer> v = new ArrayList<Integer>();

[Patch]
ArrayList<Integer> v = new ArrayList<>();