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 46b608aa [IO-811] Files.walk() direct and indirect callers fail to 
close the returned Stream<Path>
46b608aa is described below

commit 46b608aae56426a75e76de6cc14ec5f1d9e44b95
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Sep 30 09:20:01 2023 -0400

    [IO-811] Files.walk() direct and indirect callers fail to close the
    returned Stream<Path>
    
    - Javadoc
---
 src/main/java/org/apache/commons/io/FileUtils.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java 
b/src/main/java/org/apache/commons/io/FileUtils.java
index 542e9b6c..4b6a346d 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -2224,7 +2224,7 @@ public class FileUtils {
     public static Collection<File> listFiles(final File directory, final 
IOFileFilter fileFilter, final IOFileFilter dirFilter) {
         final AccumulatorPathVisitor visitor = Uncheck
             .apply(d -> listAccumulate(d, 
FileFileFilter.INSTANCE.and(fileFilter), dirFilter, 
FileVisitOption.FOLLOW_LINKS), directory);
-        return 
visitor.getFileList().stream().map(Path::toFile).collect(Collectors.toList());
+        return toList(visitor.getFileList().stream().map(Path::toFile));
     }
 
     /**
@@ -2265,7 +2265,7 @@ public class FileUtils {
             directory);
         final List<Path> list = visitor.getFileList();
         list.addAll(visitor.getDirList());
-        return list.stream().map(Path::toFile).collect(Collectors.toList());
+        return toList(list.stream().map(Path::toFile));
     }
 
     /**
@@ -3046,8 +3046,11 @@ public class FileUtils {
     }
 
     /**
-     * Consumes all of the given stream and <em>closes</em> it because 
FileTreeWalker.next() calls {@code top.stream().close()}.
-     *
+     * Consumes all of the given stream.
+     * <p>
+     * When called from a FileTreeWalker, the walker <em>closes</em> the 
stream because {@link FileTreeWalker#next()} calls {@code top.stream().close()}.
+     * </p>
+     * 
      * @param stream The stream to consume.
      * @return a new List.
      */

Reply via email to