Skip to content

Commit

Permalink
NO-JIRA Fix minor leak in FileMoveManagerTest
Browse files Browse the repository at this point in the history
Not closing the InputStream makes this test flaky on Windows. The test
breaks because FileMoveManager::delete(java.io.File) Line 221 fails
to delete the file if it's still "owned" by the JVM process on Windows.
  • Loading branch information
frohwerk authored and clebertsuconic committed Nov 13, 2018
1 parent 366005e commit 32fd445
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -352,11 +352,12 @@ private void createFile(File folder, int i) throws FileNotFoundException {

private void checkFile(File bkpFolder, String file) throws IOException {
File fileRead = new File(bkpFolder, file);
InputStreamReader stream = new InputStreamReader(new FileInputStream(fileRead));
BufferedReader reader = new BufferedReader(stream);
String valueRead = reader.readLine();
int id = Integer.parseInt(file.substring(0, file.indexOf('.')));
Assert.assertEquals("content of the file wasn't the expected", id, Integer.parseInt(valueRead));
try (InputStreamReader stream = new InputStreamReader(new FileInputStream(fileRead))) {
BufferedReader reader = new BufferedReader(stream);
String valueRead = reader.readLine();
int id = Integer.parseInt(file.substring(0, file.indexOf('.')));
Assert.assertEquals("content of the file wasn't the expected", id, Integer.parseInt(valueRead));
}
}

}

0 comments on commit 32fd445

Please sign in to comment.