[Demonstration 1]

[Buggy Method]
public Observable<List<File>> asListObservable(Scheduler scheduler) {
    checkNotNull(mFileList, "the image list cannot be null, please call .load() before this method!");
    List<Observable<File>> observables = new ArrayList<>();
    for (File file : mFileList) {
        observables.add(Observable.just(file).map(new Func1<File, File>() {

            @Override
            public File call(File file) {
                return compressImage(gear, file);
            }
        }));
    }
    return Observable.zip(observables, new FuncN<List<File>>() {

        @Override
        public List<File> call(Object... args) {
            List<File> images = new ArrayList<>();
            for (Object o : args) {
                if (o instanceof File) {
                    images.add((File) o);
                }
            }
            return images;
        }
    }).subscribeOn(scheduler);
}

[Buggy Hunk]
}));

[Patch]
}).subscribeOn(scheduler));

[Demonstration 2]

[Buggy Method]
public void run() {
    double blockSummary;
    double absoluteDifference, throshold;
    double mean = 0;
    double standardDeviation = 0, maxStandardDeviation = Double.MIN_VALUE, minStandardDeviation = Double.MAX_VALUE;
    ImmutableList<ImmutableList<String>> block;
    List<Double> summaries = new ArrayList<>();
    try {
        for (int i = 0; i < 2; i++) {
            block = stream.head(blockSize);
            stream.discard(block.size());
            summaries.add(summaryOf(block));
        }
        while (true) {
            block = stream.head(blockSize);
            stream.discard(block.size());
            blockSummary = summaryOf(block);
            if (summaries.size() > 1) {
                // Calculate the mean.
                mean = 0;
                for (double summary : summaries) {
                    mean += summary;
                }
                mean /= summaries.size();
                // Calculate the standard deviation.
                standardDeviation = 0;
                for (double summary : summaries) {
                    standardDeviation += Math.pow(summary - mean, 2);
                }
                standardDeviation /= summaries.size();
                // Update `maxStandardDeviation` and `minStandardDeviation` if needed.
                if (maxStandardDeviation < standardDeviation) {
                    maxStandardDeviation = standardDeviation;
                } else if (minStandardDeviation > standardDeviation) {
                    minStandardDeviation = standardDeviation;
                }
            } else if (summaries.size() == 1) {
                mean = summaries.get(0);
                standardDeviation = (minStandardDeviation + maxStandardDeviation) / 2;
            }
            String color;
            absoluteDifference = Math.abs(blockSummary - mean);
            throshold = driftCoefficient * standardDeviation;
            if (absoluteDifference >= throshold) {
                color = "\033[1;32m";
                summaries.clear();
            } else {
                color = "\033[1;31m";
            }
            System.out.println(color + "*** DIFF: " + absoluteDifference + ", THRESHOLD: " + throshold + " ***\033[0m");
            summaries.add(blockSummary);
        }
    } catch (NoSuchElementException e) {
        System.out.println("Done.");
    }
}

[Buggy Hunk]
standardDeviation /= summaries.size();

[Patch]
standardDeviation = Math.sqrt(standardDeviation / summaries.size());

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