[Demonstration 1]

[Buggy Method]
public void loadClaimsByUserName(String userName) {
    if (DataManager.isNetworkAvailable()) {
        //Start an Async task to load claims
        new LoadASyncTask().execute(userName);
    } else {
        local.LoadClaims(userName, DataManager.getCurrentContext());
    }
}

[Buggy Hunk]
local.LoadClaims(userName, DataManager.getCurrentContext());

[Patch]
local.LoadClaims(DataManager.getCurrentContext());

[Demonstration 2]

[Buggy Method]
private void registerEndPoints(Set<HttpService> httpServicePlugins) {
    SwaggerReader reader = new SwaggerReader(swagger);
    httpServicePlugins.forEach(service -> {
        reader.read(service.getClass());
        if (!service.getClass().isAnnotationPresent(Path.class)) {
            throw new IllegalStateException(format("HttpService class %s must have javax.ws.rs.Path annotation", service.getClass()));
        }
        String mainPath = service.getClass().getAnnotation(Path.class).value();
        if (mainPath == null) {
            throw new IllegalStateException(format("Classes that implement HttpService must have %s annotation.", Path.class.getCanonicalName()));
        }
        RouteMatcher.MicroRouteMatcher microRouteMatcher = new RouteMatcher.MicroRouteMatcher(routeMatcher, mainPath);
        for (Method method : service.getClass().getMethods()) {
            Path annotation = method.getAnnotation(Path.class);
            if (annotation != null) {
                String lastPath = annotation.value();
                JsonRequest jsonRequest = method.getAnnotation(JsonRequest.class);
                boolean mapped = false;
                for (Annotation ann : method.getAnnotations()) {
                    javax.ws.rs.HttpMethod methodAnnotation = ann.annotationType().getAnnotation(javax.ws.rs.HttpMethod.class);
                    if (methodAnnotation != null) {
                        HttpRequestHandler handler = null;
                        HttpMethod httpMethod = HttpMethod.valueOf(methodAnnotation.value());
                        try {
                            if (jsonRequest != null && httpMethod == HttpMethod.GET) {
                                throw new IllegalStateException("JsonRequest annotation can only be used with POST requests");
                            } else if (httpMethod == HttpMethod.POST) {
                                mapped = true;
                                if (method.getParameterCount() == 1 && method.getParameters()[0].getAnnotation(ParamBody.class) != null) {
                                    handler = createPostRequestHandler(service, method);
                                } else {
                                    handler = createParametrizedPostRequestHandler(service, method);
                                }
                            } else if (httpMethod == HttpMethod.GET && !method.getReturnType().equals(void.class)) {
                                mapped = true;
                                handler = createGetRequestHandler(service, method);
                            } else {
                                handler = generateRequestHandler(service, method);
                            }
                        } catch (Throwable e) {
                            //                                throw new RuntimeException(format(REQUEST_HANDLER_ERROR_MESSAGE,
                            //                                        method.getClass().getName(), method.getName(), e));
                            throw new RuntimeException(e.getMessage());
                        }
                        microRouteMatcher.add(lastPath.equals("/") ? "" : lastPath, httpMethod, handler);
                    }
                }
                if (!mapped && jsonRequest != null) {
                    //                        throw new IllegalStateException(format("Methods that have @JsonRequest annotation must also include one of HTTPStatus annotations. %s", method.toString()));
                    try {
                        if (method.getParameterCount() == 1 && method.getParameters()[0].getAnnotation(ParamBody.class) != null) {
                            microRouteMatcher.add(lastPath, HttpMethod.POST, createPostRequestHandler(service, method));
                        } else {
                            microRouteMatcher.add(lastPath, HttpMethod.POST, createParametrizedPostRequestHandler(service, method));
                        }
                    } catch (Throwable e) {
                        throw new RuntimeException(format(REQUEST_HANDLER_ERROR_MESSAGE, method.getDeclaringClass().getName(), method.getName(), e));
                    }
                }
            }
        }
    });
}

[Buggy Hunk]
}else if (httpMethod == HttpMethod.POST) {

[Patch]
}else if (jsonRequest != null && httpMethod == HttpMethod.POST) {

[Demonstration 3]

[Buggy Method]
private void checkAndFetchResults(final int amountRead, final ByteBuffer dst, final SingleResultCallback<Integer> callback) {
    if (currentPosition == fileInfo.getLength() || dst.remaining() == 0) {
        callback.onResult(amountRead, null);
    } else if (!resultsQueue.isEmpty()) {
        processResults(amountRead, dst, callback);
    } else if (cursor == null) {
        chunksCollection.find(new Document("files_id", fileInfo.getId()).append("n", new Document("$gte", chunkIndex))).batchSize(batchSize).sort(new Document("n", 1)).batchCursor(new SingleResultCallback<AsyncBatchCursor<Document>>() {

            @Override
            public void onResult(final AsyncBatchCursor<Document> result, final Throwable t) {
                if (t != null) {
                    callback.onResult(null, t);
                } else {
                    cursor = result;
                    checkAndFetchResults(amountRead, dst, callback);
                }
            }
        });
    } else {
        cursor.next(new SingleResultCallback<List<Document>>() {

            @Override
            public void onResult(final List<Document> result, final Throwable t) {
                if (t != null) {
                    callback.onResult(null, t);
                } else if (result == null || result.isEmpty()) {
                    callback.onResult(null, chunkNotFound(chunkIndex));
                } else {
                    resultsQueue.addAll(result);
                    if (batchSize == 1) {
                        discardCursor();
                    }
                    processResults(amountRead, dst, callback);
                }
            }
        });
    }
}

[Buggy Hunk]
} else if (!resultsQueue.isEmpty()) {

[Patch]
} else if (hasResultsToProcess()) {