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 a8ceea9a2 Avoid possible NullPointerException in FileUtils.listAccumulate(File, IOFileFilter, IOFileFilter, FileVisitOption...) a8ceea9a2 is described below commit a8ceea9a22cfe51dbaa170feb4ae63182db31254 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Apr 1 09:51:39 2024 -0400 Avoid possible NullPointerException in FileUtils.listAccumulate(File, IOFileFilter, IOFileFilter, FileVisitOption...) --- src/changes/changes.xml | 3 ++- src/main/java/org/apache/commons/io/FileUtils.java | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 3627df4df..43952d025 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -49,7 +49,8 @@ The <action> type attribute can be add,update,fix,remove. <release version="2.16.1" date="YYYY-MM-DD" description="Java 8 is required."> <!-- FIX --> <action dev="ggregory" type="fix" due-to="Gary Gregory">Reimplement FileSystemUtils using NIO.</action> - <action dev="ggregory" type="fix" issue="IO-851" due-to="Sebb, Gary Gregory">FileSystemUtils no longer throws IllegalStateException.</action> + <action dev="ggregory" type="fix" issue="IO-851" due-to="Sebb, Gary Gregory">FileSystemUtils no longer throws IllegalStateException.</action> + <action dev="ggregory" type="fix" due-to="Gary Gregory">Avoid possible NullPointerException in FileUtils.listAccumulate(File, IOFileFilter, IOFileFilter, FileVisitOption...).</action> <!-- UPDATE --> <action dev="ggregory" type="update" due-to="Gary Gregory">Bump commons.bytebuddy.version from 1.14.12 to 1.14.13 #605.</action> </release> diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index f8959ae1c..4879fc88c 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -2230,14 +2230,16 @@ public class FileUtils { } private static AccumulatorPathVisitor listAccumulate(final File directory, final IOFileFilter fileFilter, final IOFileFilter dirFilter, - final FileVisitOption... options) throws IOException { + final FileVisitOption... options) throws IOException { final boolean isDirFilterSet = dirFilter != null; final FileEqualsFileFilter rootDirFilter = new FileEqualsFileFilter(directory); final PathFilter dirPathFilter = isDirFilterSet ? rootDirFilter.or(dirFilter) : rootDirFilter; final AccumulatorPathVisitor visitor = new AccumulatorPathVisitor(Counters.noopPathCounters(), fileFilter, dirPathFilter, - (p, e) -> FileVisitResult.CONTINUE); + (p, e) -> FileVisitResult.CONTINUE); final Set<FileVisitOption> optionSet = new HashSet<>(); - Collections.addAll(optionSet, options); + if (options != null) { + Collections.addAll(optionSet, options); + } Files.walkFileTree(directory.toPath(), optionSet, toMaxDepth(isDirFilterSet), visitor); return visitor; }