[Demonstration 1]

[Buggy Method]
protected static CollectorConfiguration loadConfig(String uri, String type) {
    final CollectorConfiguration config = new CollectorConfiguration();
    if (type == null) {
        type = DEFAULT_TYPE;
    }
    uri += java.io.File.separator + type;
    File f = new File(uri);
    if (!f.isAbsolute()) {
        if (f.exists()) {
            uri = f.getAbsolutePath();
        } else if (System.getProperties().containsKey("jboss.server.config.dir")) {
            uri = System.getProperty("jboss.server.config.dir") + java.io.File.separatorChar + uri;
        } else {
            try {
                URL url = Thread.currentThread().getContextClassLoader().getResource(uri);
                if (url != null) {
                    uri = url.getPath();
                } else {
                    log.severe("Failed to get absolute path for uri '" + uri + "'");
                }
            } catch (Exception e) {
                log.log(Level.SEVERE, "Failed to get absolute path for uri '" + uri + "'", e);
                uri = null;
            }
        }
    }
    if (uri != null) {
        String[] uriParts = uri.split(java.io.File.separator);
        int startIndex = 0;
        // Remove any file prefix
        if (uriParts[0].equals("file:")) {
            startIndex++;
        }
        try {
            Path path = getPath(startIndex, uriParts);
            Files.walkFileTree(path, new FileVisitor<Path>() {

                @Override
                public FileVisitResult postVisitDirectory(Path path, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
                    if (path.toString().endsWith(".json")) {
                        String json = new String(Files.readAllBytes(path));
                        CollectorConfiguration childConfig = mapper.readValue(json, CollectorConfiguration.class);
                        if (childConfig != null) {
                            config.merge(childConfig, false);
                        }
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFileFailed(Path path, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }
            });
        } catch (Throwable e) {
            log.log(Level.SEVERE, "Failed to load configuration", e);
        }
    }
    return config;
}

[Buggy Hunk]
String[] uriParts = uri.split(java.io.File.separator);

[Patch]
String[] uriParts = uri.split(Matcher.quoteReplacement(File.separator));

[Demonstration 2]

[Buggy Method]
public boolean hasPlayerInstance(int chunkX, int chunkZ) {
    long i = (long) chunkX + 2147483647L | (long) chunkZ + 2147483647L << 32;
    return playerInstances.getValueByKey(i) != null;
}

[Buggy Hunk]
return playerInstances.getValueByKey(i) != null;

[Patch]
return this.playerInstances.getValueByKey(i) != null;

[Demonstration 3]

[Buggy Method]
private void scanDirectory(File directory) throws DataUnitException {
    LOG.debug("> scanDirectory");
    final Path directoryPath = directory.toPath();
    final Iterator<File> iter = FileUtils.iterateFiles(directory, null, true);
    while (iter.hasNext()) {
        final File newFile = iter.next();
        final String relativePath = directoryPath.relativize(newFile.toPath()).toString();
        final String newSymbolicName = relativePath;
        // add file
        outFilesData.addExistingFile(newSymbolicName, newFile.toURI().toString());
        //
        // add metadata
        //
        Manipulator.add(outFilesData, newSymbolicName, VirtualPathHelper.PREDICATE_VIRTUAL_PATH, relativePath);
    }
    LOG.debug("< scanDirectory");
}

[Buggy Hunk]
final Path directoryPath = directory.toPath();

[Patch]
final Path directoryPath = directory.getParentFile().toPath();