[Demonstration 1]

[Buggy Method]
public static ArrayList<VTLocation> getLocationNamesByString(String input) throws IOException, JSONException {
    UrlCallBuilder uBuilder = new UrlCallBuilder(baseurl, "location.name");
    uBuilder.AddParameter("input", getISO88591String(input));
    String response = httpGet(uBuilder.getUrl() + "&format=json");
    //String response = JsonTestResponses.getLocationNamesByStringArr;
    //String response = JsonTestResponses.getLocationNamesByStringObjAndArr;
    JSONObject jsonData = new JSONObject(response);
    ArrayList<VTLocation> locationList = new ArrayList<VTLocation>();
    Iterator<String> keysIter = jsonData.getJSONObject("LocationList").keys();
    while (keysIter.hasNext()) {
        key = keysIter.next();
        if (key.equals("serverdate") || key.equals("servertime") || key.equals("noNamespaceSchemaLocation"))
            continue;
        Object locations = jsonData.getJSONObject("LocationList").get(key);
        if (locations instanceof JSONArray) {
            JSONArray stopLocArr = (JSONArray) locations;
            for (int i = 0; i < stopLocArr.length(); i++) {
                VTLocation loc = getJSONLocation((JSONObject) stopLocArr.get(i));
                locationList.add(loc);
            }
        } else {
            VTLocation loc = getJSONLocation((JSONObject) locations);
            locationList.add(loc);
        }
    }
    return locationList;
}

[Buggy Hunk]
key = keysIter.next();

[Patch]
String key = keysIter.next();

[Demonstration 2]

[Buggy Method]
public static synchronized String getMessagesFrom(int start) throws SAXException, IOException, ParserConfigurationException, XPathExpressionException {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse(STORAGE_LOCATION);
    document.getDocumentElement().normalize();
    JSONArray messages = new JSONArray();
    JSONObject jsonMessage;
    jsonMessage = new JSONObject();
    Set<String> ids = XMLRequestParser.getRequests(start);
    for (String id : ids) {
        Node message = getNodeById(document, id);
        NodeList childNodes = message.getChildNodes();
        jsonMessage.put(ID, id);
        String nodeValue;
        for (int j = 0; j < childNodes.getLength(); j++) {
            Node node = childNodes.item(j);
            nodeValue = node.getTextContent();
            if (TEXT.equals(node.getNodeName())) {
                jsonMessage.put(TEXT, nodeValue);
            } else if (EDITED.equals(node.getNodeName())) {
                jsonMessage.put(EDITED, Boolean.valueOf(nodeValue));
            } else if (DELETED.equals(node.getNodeName())) {
                jsonMessage.put(DELETED, Boolean.valueOf(nodeValue));
            } else if (USERNAME.equals(node.getNodeName())) {
                jsonMessage.put(USERNAME, nodeValue);
            } else if (TIME.equals(node.getNodeName())) {
                jsonMessage.put(TIME, nodeValue);
            } else if (LOG_TIME.equals(node.getNodeName())) {
                jsonMessage.put(LOG_TIME, nodeValue);
            }
        }
        messages.put(jsonMessage);
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(MESSAGES, messages);
    jsonObject.put(TOKEN, getToken(XMLRequestParser.getRequestsAmount()));
    return jsonObject.toJSONString();
}

[Buggy Hunk]
Set<String> ids = XMLRequestParser.getRequests(start);

[Patch]
List<String> ids = XMLRequestParser.getRequests(start);

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