diff --git a/src/main/java/org/apache/commons/io/DirectoryWalker.java b/src/main/java/org/apache/commons/io/DirectoryWalker.java index e8a4a2e24f0..62298a50c13 100644 --- a/src/main/java/org/apache/commons/io/DirectoryWalker.java +++ b/src/main/java/org/apache/commons/io/DirectoryWalker.java @@ -644,7 +644,7 @@ private void walk(final File directory, final int depth, final Collection 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); diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 9b5bcd0b33d..d9ce9a3e74c 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -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);