Fix error where getResources() would return parent items first, even when
parentFirst attribute was set to false. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@394457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -21,8 +21,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
// TODO: use HashTable instead of HashMap for java1.1 support
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -235,6 +236,25 @@ public class PathableClassLoader extends URLClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as parent class method except that when parentFirst is false
|
||||
* any resources in the local classpath are returned before resources
|
||||
* in the parent.
|
||||
*/
|
||||
public Enumeration getResources(String name) throws IOException {
|
||||
if (parentFirst) {
|
||||
return super.getResources(name);
|
||||
} else {
|
||||
Enumeration localUrls = super.findResources(name);
|
||||
Enumeration parentUrls = getParent().getResources(name);
|
||||
|
||||
ArrayList localItems = Collections.list(localUrls);
|
||||
ArrayList parentItems = Collections.list(parentUrls);
|
||||
localItems.addAll(parentItems);
|
||||
return Collections.enumeration(localItems);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as parent class method except that when parentFirst is false
|
||||
* the resource is looked for in the local classpath before the parent
|
||||
|
||||
Reference in New Issue
Block a user