[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]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_img_sel);
    config = Constant.config;
    // Android 6.0 checkSelfPermission
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, STORAGE_REQUEST_CODE);
    } else {
        fragment = ImgSelFragment.instance();
        getSupportFragmentManager().beginTransaction().add(R.id.fmImageList, fragment, null).commit();
    }
    initView();
    if (!FileUtils.isSdCardAvailable()) {
        Toast.makeText(this, getString(R.string.sd_disable), Toast.LENGTH_SHORT).show();
    }
}

[Buggy Hunk]
config = Constant.config;

[Patch]
config = getDefaultConfig(this);

[Demonstration 3]

[Buggy Method]
public static void migrateChanges(String path) {
    try {
        Flyway flyway = getFlywayObj();
        //Are out of order migrations allowed? (e.g. V1 and V3 are applied but V2 is found)
        flyway.setOutOfOrder(Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.FLYWAY_OUT_OF_ORDER));
        //Experimental
        int baseLineVersion = Activator.getDefault().getPreferenceStore().getInt(PreferenceConstants.FLYWAY_BASE_VERSION);
        if (baseLineVersion > 0) {
            flyway.setBaselineVersion("" + baseLineVersion);
        }
        //Experimental
        int targetVersion = Activator.getDefault().getPreferenceStore().getInt(PreferenceConstants.FLYWAY_TARGET_VERSION);
        if (targetVersion > 0) {
            flyway.setTarget("" + targetVersion);
        }
        flyway.setLocations("filesystem:" + path);
        flyway.migrate();
        path = path.substring(0, path.length() - CHANGELOG_FOLDER.length()) + ".json";
        saveVersioInfo(path);
        StatusManager.getManager().handle(new TedaptStatus(IStatus.OK, TedaptStatusCode.MIGRATION_OK), StatusManager.LOG | StatusManager.SHOW);
    } catch (Exception ex) {
        StatusManager.getManager().handle(new TedaptStatus(IStatus.ERROR, TedaptStatusCode.MIGRATION_FAILED, ex), StatusManager.LOG | StatusManager.SHOW);
    }
}

[Buggy Hunk]
path = path.substring(0, path.length()-CHANGELOG_FOLDER.length())+".json";

[Patch]
path.replace(CHANGELOG_FOLDER, ".json");