[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]
public long downloadUpdateFile(String downloadUrl) throws Exception {
    int downloadCount = 0;
    int currentSize = 0;
    long totalSize = 0;
    int updateTotalSize = 0;
    HttpURLConnection httpConnection = null;
    InputStream is = null;
    FileOutputStream fos = null;
    try {
        URL url = new URL(downloadUrl);
        httpConnection = (HttpURLConnection) url.openConnection();
        if (currentSize > 0) {
            httpConnection.setRequestProperty("RANGE", "bytes=" + currentSize + "-");
        }
        httpConnection.setConnectTimeout(10000);
        httpConnection.setReadTimeout(20000);
        updateTotalSize = httpConnection.getContentLength();
        if (httpConnection.getResponseCode() == 404) {
            throw new Exception("fail!");
        }
        is = httpConnection.getInputStream();
        fos = getApplicationContext().openFileOutput(fileName, MODE_WORLD_READABLE);
        byte[] buffer = new byte[4096];
        int readsize = 0;
        while ((readsize = is.read(buffer)) > 0) {
            fos.write(buffer, 0, readsize);
            totalSize += readsize;
            if ((downloadCount == 0) || (int) (totalSize * 100 / updateTotalSize) - 10 > downloadCount) {
                downloadCount += 10;
                Intent nullIntent = new Intent();
                PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, nullIntent, 0);
                mBuilder.setContentIntent(pendingIntent).setContentTitle(getApplication().getResources().getString(R.string.download)).setContentText((int) totalSize * 100 / updateTotalSize + "%").setSmallIcon(drawableId);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    updateNotification = mBuilder.build();
                } else {
                    updateNotification = mBuilder.getNotification();
                }
                updateNotificationManager.notify(101, updateNotification);
            }
        }
    } finally {
        if (httpConnection != null) {
            httpConnection.disconnect();
        }
        if (is != null) {
            is.close();
        }
        if (fos != null) {
            fos.close();
        }
    }
    return totalSize;
}

[Buggy Hunk]
fos = getApplicationContext().openFileOutput(fileName, MODE_WORLD_READABLE);

[Patch]
fos = getApplicationContext().openFileOutput(fileName, versionAboveN() ? MODE_PRIVATE : MODE_WORLD_READABLE);

[Demonstration 3]

[Buggy Method]
private String etag() throws IOException {
    return s3client.getObjectMetadata(bucket, key).getETag();
}

[Buggy Hunk]
private String etag() throws IOException {

[Patch]
private String etag() {