NO-JIRA Fix minor leak in FileMoveManagerTest

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.
This commit is contained in:
Andreas Frohwerk 2018-11-13 22:23:44 +01:00 committed by Clebert Suconic
parent 366005e44f
commit 32fd445dd2
1 changed files with 6 additions and 5 deletions

View File

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