This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push: new b1cdc129 [IO-811] Files.walk() direct and indirect callers fail to close the returned Stream<Path> b1cdc129 is described below commit b1cdc129b7f097ffcd0d5a05d03c16d6b8d0af80 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Sep 30 09:11:56 2023 -0400 [IO-811] Files.walk() direct and indirect callers fail to close the returned Stream<Path> - Release resource in test --- .../io/function/IOBinaryOperatorStreamTest.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/apache/commons/io/function/IOBinaryOperatorStreamTest.java b/src/test/java/org/apache/commons/io/function/IOBinaryOperatorStreamTest.java index a591e780..501d75f8 100644 --- a/src/test/java/org/apache/commons/io/function/IOBinaryOperatorStreamTest.java +++ b/src/test/java/org/apache/commons/io/function/IOBinaryOperatorStreamTest.java @@ -88,14 +88,19 @@ public class IOBinaryOperatorStreamTest { public void testReduce() throws IOException { // A silly example to pass in a IOBinaryOperator. final Path current = PathUtils.current(); - final Path expected = Files.list(current).reduce((t, u) -> { - try { - return t.toRealPath(); - } catch (final IOException e) { - return fail(e); - } - }).get(); - assertEquals(expected, Files.list(current).reduce(REAL_PATH_BO).get()); + final Path expected; + try (Stream<Path> stream = Files.list(current)) { + expected = stream.reduce((t, u) -> { + try { + return t.toRealPath(); + } catch (final IOException e) { + return fail(e); + } + }).get(); + } + try (Stream<Path> stream = Files.list(current)) { + assertEquals(expected, stream.reduce(REAL_PATH_BO).get()); + } } }