diff --git a/src/test/org/apache/commons/logging/PathableClassLoader.java b/src/test/org/apache/commons/logging/PathableClassLoader.java index 17c5886..a74cf3d 100644 --- a/src/test/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/org/apache/commons/logging/PathableClassLoader.java @@ -245,6 +245,11 @@ public class PathableClassLoader extends URLClassLoader { * jarfile in the path whose name starts with the logicalLib string is * considered a match. For example, passing "foo" will match a url * of file:///some/where/foo-2.7.jar. + *

+ * When multiple classpath entries match the specified logicalLib string, + * the one with the shortest filename component is returned. This means that + * if "foo-1.1.jar" and "foobar-1.1.jar" are in the path, then a logicalLib + * name of "foo" will match the first entry above. */ private URL libFromClasspath(String logicalLib) { ClassLoader cl = this.getClass().getClassLoader(); @@ -254,6 +259,8 @@ public class PathableClassLoader extends URLClassLoader { URLClassLoader ucl = (URLClassLoader) cl; URL[] path = ucl.getURLs(); + URL shortestMatch = null; + int shortestMatchLen = Integer.MAX_VALUE; for(int i=0; i