What steps will reproduce the problem?
Pass in a package prefix to Reflections.collect which doesn't return any
valid entries. Looks like the underlying problem is that
ClasspathHelper.getUrlsForPackagePrefix correctly returns an empty list,
which gets passed to Vfs.findFiles, but this then returns null.
What is the expected output? What do you see instead?
Vfs.findFiles should return at least an empty list; instead get null and
then a NPE when Reflections.collect tries to iterate
What version of the product are you using? On what operating system?
0.9.5-RC1, Windows
Please provide any additional information below.
Suggested patch:
Index: src/main/java/org/reflections/vfs/Vfs.java
===================================================================
--- src/main/java/org/reflections/vfs/Vfs.java (revision 78)
+++ src/main/java/org/reflections/vfs/Vfs.java (working copy)
@@ -11,6 +11,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -112,11 +113,11 @@
/** return an iterable of all {@link org.reflections.vfs.Vfs.File} in
given urls, matching filePredicate */
public static Iterable<File> findFiles(final List<URL> inUrls, final
Predicate<File> filePredicate) {
- Iterable<File> result = null;
+ Iterable<File> result = new ArrayList<File>();
for (URL url : inUrls) {
Iterable<File> iterable =
Iterables.filter(fromURL(url).getFiles(), filePredicate);
- result = result == null ? iterable : Iterables.concat(result,
iterable);
+ result = Iterables.concat(result, iterable);
}
return result;
Original issue reported on code.google.com by ashley.m...@gmail.com on 2 Mar 2010 at 10:22
Original issue reported on code.google.com by
ashley.m...@gmail.com
on 2 Mar 2010 at 10:22