[Demonstration 1]

[Buggy Method]
public void onFail(int httpStatus, Map<String, String> errors) {
    if (getScope().isLoading()) {
        getScope().setLoading(false);
    }
    if (errors != null && !errors.isEmpty()) {
        Iterator<String> it = errors.keySet().iterator();
        EnumError error = EnumError.find(Integer.valueOf(it.next()));
        display(EnumErrorRes.find(error).getResID());
    } else {
        EnumHttpStatus status = EnumHttpStatus.find(httpStatus);
        if (status != null) {
            display(status.getDesc());
        } else {
            display(EnumErrorRes.UNKNOWN.getResID());
        }
    }
}

[Buggy Hunk]
if (getScope().isLoading()) {

[Patch]
if (getScope() != null && getScope().isLoading()) {

[Demonstration 2]

[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 3]

[Buggy Method]
public static void main(String[] args) throws IOException {
    //	String basePath = args[0];
    Path basePath = Paths.get(args[0]);
    final int maxBlocks = args.length >= 2 ? Integer.parseInt(args[1]) : Integer.MAX_VALUE;
    Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {

        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            String fileNameLowerCase = file.getFileName().toString().toLowerCase();
            if (file.toFile().isFile() == false) {
                return FileVisitResult.CONTINUE;
            }
            if (fileNameLowerCase.endsWith(".jpg") || fileNameLowerCase.endsWith(".nef")) {
                try (InputStream is = new BufferedInputStream(Files.newInputStream(file))) {
                    MessageDigest md;
                    try {
                        md = MessageDigest.getInstance("md5");
                    } catch (NoSuchAlgorithmException e) {
                        throw new RuntimeException(e);
                    }
                    byte[] buf = new byte[4096];
                    int read;
                    int nBlocks = 0;
                    while (nBlocks < maxBlocks && (read = is.read(buf)) > 0) {
                        md.update(buf, 0, read);
                        nBlocks++;
                    }
                    byte[] digest = md.digest();
                    String myChecksum = DatatypeConverter.printHexBinary(digest).toUpperCase();
                    System.out.println(myChecksum + " " + file.toFile().getAbsolutePath());
                }
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
            if (exc == null) {
                return FileVisitResult.CONTINUE;
            } else {
                exc.printStackTrace();
                return FileVisitResult.SKIP_SUBTREE;
            }
        }

        @Override
        public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
            if (exc == null) {
                if (dir.startsWith(".")) {
                    return FileVisitResult.SKIP_SUBTREE;
                } else {
                    return FileVisitResult.CONTINUE;
                }
            } else {
                exc.printStackTrace();
                return FileVisitResult.SKIP_SUBTREE;
            }
        }
    });
}

[Buggy Hunk]
if (dir.startsWith(".")) {

[Patch]
if (dir.getFileName().startsWith(".")) {