1
0

Handle case of null parent classloader

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@394463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Kitching
2006-04-16 12:01:57 +00:00
parent 76cc63f74c
commit 0ad40253d6

View File

@@ -246,7 +246,22 @@ public class PathableClassLoader extends URLClassLoader {
return super.getResources(name); return super.getResources(name);
} else { } else {
Enumeration localUrls = super.findResources(name); Enumeration localUrls = super.findResources(name);
Enumeration parentUrls = getParent().getResources(name);
ClassLoader parent = getParent();
if (parent == null) {
// Alas, there is no method to get matching resources
// from a null (BOOT) parent classloader. Calling
// ClassLoader.getSystemClassLoader isn't right. Maybe
// calling Class.class.getResources(name) would do?
//
// However for the purposes of unit tests, we can
// simply assume that no relevant resources are
// loadable from the parent; unit tests will never be
// putting any of their resources in a "boot" classloader
// path!
return localUrls;
}
Enumeration parentUrls = parent.getResources(name);
ArrayList localItems = Collections.list(localUrls); ArrayList localItems = Collections.list(localUrls);
ArrayList parentItems = Collections.list(parentUrls); ArrayList parentItems = Collections.list(parentUrls);