Skip to content

Commit 6931ffe

Browse files
committed
[IO-811] Files.walk() direct and indirect callers fail to close the
returned Stream<Path> - Release resource in test
1 parent bec1893 commit 6931ffe

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/test/java/org/apache/commons/io/file/FilesUncheckTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,16 @@ public void testWalkFileTreePathSetOfFileVisitOptionIntFileVisitorOfQsuperPath()
435435

436436
@Test
437437
public void testWalkPathFileVisitOptionArray() {
438-
assertTrue(0 < FilesUncheck.walk(TARGET_PATH, FileVisitOption.FOLLOW_LINKS).count());
438+
try (Stream<Path> stream = FilesUncheck.walk(TARGET_PATH, FileVisitOption.FOLLOW_LINKS)) {
439+
assertTrue(0 < stream.count());
440+
}
439441
}
440442

441443
@Test
442444
public void testWalkPathIntFileVisitOptionArray() {
443-
assertEquals(1, FilesUncheck.walk(TARGET_PATH, 0, FileVisitOption.FOLLOW_LINKS).count());
445+
try (Stream<Path> stream = FilesUncheck.walk(TARGET_PATH, 0, FileVisitOption.FOLLOW_LINKS)) {
446+
assertEquals(1, stream.count());
447+
}
444448
}
445449

446450
@Test

0 commit comments

Comments
 (0)