[Demonstration 1]

[Buggy Method]
@SuppressWarnings("unchecked")
@Test
public void testFileStream() throws IOException {
    File testDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"));
    List<List<String>> expected = fileTestPrepare(testDir);
    JavaPairInputDStream<LongWritable, Text> inputStream = ssc.fileStream(testDir.toString(), LongWritable.class, Text.class, TextInputFormat.class, new Function<Path, Boolean>() {

        @Override
        public Boolean call(Path v1) throws Exception {
            return Boolean.TRUE;
        }
    }, true);
    JavaDStream<String> test = inputStream.map(new Function<Tuple2<LongWritable, Text>, String>() {

        @Override
        public String call(Tuple2<LongWritable, Text> v1) throws Exception {
            return v1._2().toString();
        }
    });
    JavaTestUtils.attachTestOutputStream(test);
    List<List<String>> result = JavaTestUtils.runStreams(ssc, 1, 1);
    assertOrderInvariantEquals(expected, result);
}

[Buggy Hunk]
File testDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"));

[Patch]
File testDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");

[Demonstration 2]

[Buggy Method]
@Test
public void submitForm() throws IOException {
    File fileToUpload = new File(Dirs.getTmp(), "upload.txt");
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileToUpload)))) {
        bw.write("This is the content of the file");
    }
    String formUrl = getTestUrl("files/fileUpload.html");
    String script = String.format("b = pizza.open(\"%s\");\n" + "b.setFile('#file', '%s');\n" + "b.submit('#fileUploadForm');\n" + "b.waitPageLoad();\n", formUrl, fileToUpload.getAbsolutePath());
    TestResult result = runScript(script);
    assertNoError(result);
    assertEquals(2, result.getPages().size());
    Page post = result.getLastPage();
    assertEquals(NavigationType.FormSubmit, post.getNavigationType());
    HttpRequest postRequest = getFirstRequest(post);
    assertEquals(postRequest.getMethod(), "POST");
    assertNotNull(postRequest.getPostData());
}

[Buggy Hunk]
fileToUpload.getAbsolutePath());

[Patch]
escapeWindowsPath(fileToUpload.getAbsolutePath()));

[Demonstration 3]

[Buggy Method]
public static void deleteFolder(FileType type) {
    if (type == FileType.LAST_RUN_COMMIT) {
        File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + type + File.separator);
        if (!dir.exists()) {
            dir.mkdir();
        } else {
            for (File file : dir.listFiles()) {
                if (!file.isDirectory())
                    file.delete();
            }
        }
    } else if (type == FileType.IS_RUNNING_FILE) {
        File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + "running" + File.separator);
        if (!dir.exists()) {
            dir.mkdir();
        } else {
            for (File file : dir.listFiles()) {
                if (!file.isDirectory())
                    file.delete();
            }
        }
    } else if (type == FileType.IS_CLONING_FILE) {
        File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + "cloning" + File.separator);
        if (!dir.exists()) {
            dir.mkdir();
        } else {
            for (File file : dir.listFiles()) {
                if (!file.isDirectory())
                    file.delete();
            }
        }
    } else if (type == FileType.COMMIT_QUEUE) {
        File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + "commit_queue" + File.separator);
        if (!dir.exists()) {
            dir.mkdir();
        } else {
            for (File file : dir.listFiles()) {
                if (!file.isDirectory())
                    file.delete();
            }
        }
    }
}

[Buggy Hunk]
File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + type + File.separator);

[Patch]
File dir = new File(BenchmarkAppConnector.benchmarkAppDirectory + "data" + File.separator + "lastrun" + File.separator);