Skip to content

Commit 3fbb4f3

Browse files
committed
It is OK to call java.io.File.listFiles(FileFilter) with a null argument
See the Javadoc
1 parent e313a62 commit 3fbb4f3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/org/apache/commons/io/DirectoryWalker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ private void walk(final File directory, final int depth, final Collection<T> res
644644
final int childDepth = depth + 1;
645645
if (depthLimit < 0 || childDepth <= depthLimit) {
646646
checkIfCancelled(directory, depth, results);
647-
File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter);
647+
File[] childFiles = directory.listFiles(filter);
648648
childFiles = filterDirectoryContents(directory, depth, childFiles);
649649
if (childFiles == null) {
650650
handleRestricted(directory, childDepth, results);

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@ private static AccumulatorPathVisitor listAccumulate(final File directory, final
23062306
*/
23072307
private static File[] listFiles(final File directory, final FileFilter fileFilter) throws IOException {
23082308
requireDirectoryExists(directory, "directory");
2309-
final File[] files = fileFilter == null ? directory.listFiles() : directory.listFiles(fileFilter);
2309+
final File[] files = directory.listFiles(fileFilter);
23102310
if (files == null) {
23112311
// null if the directory does not denote a directory, or if an I/O error occurs.
23122312
throw new IOException("Unknown I/O error listing contents of directory: " + directory);

0 commit comments

Comments
 (0)