diff --git a/src/test/org/apache/commons/logging/PathableClassLoader.java b/src/test/org/apache/commons/logging/PathableClassLoader.java index d8c0ef4..208ba47 100644 --- a/src/test/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/org/apache/commons/logging/PathableClassLoader.java @@ -270,13 +270,32 @@ public class PathableClassLoader extends URLClassLoader { } Enumeration parentUrls = parent.getResources(name); - ArrayList localItems = Collections.list(localUrls); - ArrayList parentItems = Collections.list(parentUrls); + ArrayList localItems = toList(localUrls); + ArrayList parentItems = toList(parentUrls); localItems.addAll(parentItems); return Collections.enumeration(localItems); } } + /** + * + * Clean implementation of list function of + * {@link java.utils.Collection} added in JDK 1.4 + * @param en Enumeration, possibly null + * @return ArrayList containing the enumerated + * elements in the enumerated order, not null + */ + private ArrayList toList(Enumeration en) { + ArrayList results = new ArrayList(); + if (en != null) { + while (en.hasMoreElements()){ + Object element = en.nextElement(); + results.add(element); + } + } + return results; + } + /** * Same as parent class method except that when parentFirst is false * the resource is looked for in the local classpath before the parent