Skip to content

Commit 65b3c8a

Browse files
committed
BugZilla #25742:
Change listFiles so its behaviour matches the javadocs. Fixes NPE when extension is null. Submitted by: Ignat Skoryh <ignat.at.tiger.unisquad.com> git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140448 13f79535-47bb-0310-9956-ffa450edef68
1 parent 62933fa commit 65b3c8a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
* @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
117117
* @author Matthew Hawthorne
118118
* @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
119-
* @version $Id: FileUtils.java,v 1.19 2003/11/23 20:43:30 bayard Exp $
119+
* @version $Id: FileUtils.java,v 1.20 2003/12/25 11:05:59 jeremias Exp $
120120
*/
121121
public class FileUtils {
122122

@@ -276,8 +276,13 @@ public static String[] toSuffixes(final String[] extensions) {
276276
* @return an collection of java.io.File with the matching files
277277
*/
278278
public static Collection listFiles(File directory, String[] extensions, boolean recursive) {
279-
String[] suffixes = toSuffixes(extensions);
280-
IOFileFilter filter = new SuffixFileFilter(suffixes);
279+
IOFileFilter filter;
280+
if (extensions == null) {
281+
filter = TrueFileFilter.INSTANCE;
282+
} else {
283+
String[] suffixes = toSuffixes(extensions);
284+
filter = new SuffixFileFilter(suffixes);
285+
}
281286
return listFiles(directory, filter,
282287
(recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE));
283288
}

0 commit comments

Comments
 (0)