[Demonstration 1]

[Buggy Method]
protected HttpPost buildRequest(ModelNode model) throws UnsupportedEncodingException {
    HttpPost request = new HttpPost(url);
    request.addHeader("Content-Type", "application/json");
    request.setEntity(new StringEntity(model.toJSONString(true)));
    return request;
}

[Buggy Hunk]
request.addHeader("Content-Type", "application/json");

[Patch]
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());

[Demonstration 2]

[Buggy Method]
@Override
protected String doInBackground(String... sUrl) {
    ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
    InputStream input = null;
    OutputStream output = null;
    HttpURLConnection connection = null;
    int count;
    byte[] data;
    if (imageType.equals(Helper.IMAGE_TYPE_TXT)) {
        Log.d("filePath", Integer.toString(sUrl.length));
        try {
            URL url = new URL(sUrl[0]);
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();
            // expect HTTP 200 OK, so we don't mistakenly save error report
            // instead of the file
            if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                return "Server returned HTTP " + connection.getResponseCode() + " " + connection.getResponseMessage();
            }
            // download the file
            input = connection.getInputStream();
            output = new FileOutputStream(Helper.getOutputMediaFile(Helper.getTxtFileName()));
            data = new byte[Helper.READBYTE];
            while ((count = input.read(data)) != -1) {
                // allow canceling with back button
                if (isCancelled()) {
                    input.close();
                    return null;
                }
                byteOutputStream.write(data, 0, count);
                output.write(data, 0, count);
            }
        } catch (Exception e) {
            return e.toString();
        } finally {
            try {
                if (output != null) {
                    mNumUpdated = Helper.populateDatabase(mDataBase, byteOutputStream);
                    output.close();
                }
                if (input != null)
                    input.close();
            } catch (IOException ignored) {
            }
            if (connection != null)
                connection.disconnect();
        }
    } else {
        //Helper.IMAGE_TYPE_JPG
        for (int k = 0; k < sUrl.length; k++) {
            try {
                URL url = new URL(sUrl[k]);
                connection = (HttpURLConnection) url.openConnection();
                connection.connect();
                // expect HTTP 200 OK, so we don't mistakenly save error report
                // instead of the file
                if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                    return "Server returned HTTP " + connection.getResponseCode() + " " + connection.getResponseMessage();
                }
                // download the file
                //                        mDataBase.getCursor().moveToPosition(k);
                input = connection.getInputStream();
                output = new FileOutputStream(Helper.getImageOutputMediaFile(allImageNames[k]));
                bitmap = BitmapFactory.decodeStream(input);
                try {
                    bitmap.compress(Bitmap.CompressFormat.JPEG, 90, output);
                    output.close();
                } catch (FileNotFoundException e) {
                } catch (IOException e) {
                }
            } catch (Exception e) {
                return e.toString();
            } finally {
                try {
                    if (output != null) {
                        output.close();
                    }
                    if (input != null)
                        input.close();
                } catch (IOException ignored) {
                }
                if (connection != null)
                    connection.disconnect();
            }
        }
    }
    return null;
}

[Buggy Hunk]
mNumUpdated = Helper.populateDatabase(mDataBase, byteOutputStream);

[Patch]
Helper.mNumUpdated = Helper.populateDatabase(mDataBase, byteOutputStream);

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