Skip to content

Commit

Permalink
It is OK to call java.io.File.listFiles(FileFilter) with a null argument
Browse files Browse the repository at this point in the history
See the Javadoc
  • Loading branch information
garydgregory committed Nov 14, 2024
1 parent e313a62 commit 3fbb4f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/io/DirectoryWalker.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ private void walk(final File directory, final int depth, final Collection<T> res
final int childDepth = depth + 1;
if (depthLimit < 0 || childDepth <= depthLimit) {
checkIfCancelled(directory, depth, results);
File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter);
File[] childFiles = directory.listFiles(filter);
childFiles = filterDirectoryContents(directory, depth, childFiles);
if (childFiles == null) {
handleRestricted(directory, childDepth, results);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/io/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,7 @@ private static AccumulatorPathVisitor listAccumulate(final File directory, final
*/
private static File[] listFiles(final File directory, final FileFilter fileFilter) throws IOException {
requireDirectoryExists(directory, "directory");
final File[] files = fileFilter == null ? directory.listFiles() : directory.listFiles(fileFilter);
final File[] files = directory.listFiles(fileFilter);
if (files == null) {
// null if the directory does not denote a directory, or if an I/O error occurs.
throw new IOException("Unknown I/O error listing contents of directory: " + directory);
Expand Down

0 comments on commit 3fbb4f3

Please sign in to comment.