diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index fc604a4adf0..5908571fb06 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -447,8 +447,8 @@ public abstract class Resource implements ResourceFactory, Closeable /* ------------------------------------------------------------ */ /** * list of resource names contained in the given resource. - * - * @return a list of resource names contained in the given resource. + * Ordering is unspecified, so callers may wish to sort the return value to ensure deterministic behavior. + * @return a list of resource names contained in the given resource, or null. * Note: The resource names are not URL encoded. */ public abstract String[] list(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java index d46a0858717..60ebf846151 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java @@ -438,7 +438,7 @@ public class ResourceCollection extends Resource set.add(s); } String[] result=set.toArray(new String[set.size()]); - Arrays.sort(result); + Arrays.sort(result); // TODO still necessary? return result; } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java index bc4c855b226..ef0236ba92a 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java @@ -29,6 +29,7 @@ import java.security.CodeSource; import java.security.PermissionCollection; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; @@ -324,10 +325,15 @@ public class WebAppClassLoader extends URLClassLoader */ public void addJars(Resource lib) { - if (lib.exists() && lib.isDirectory()) + if (lib.exists() && lib.isDirectory()) // TODO perhaps redundant given null check from list()? { String[] files=lib.list(); - for (int f=0;files!=null && f resources = _loader.getResources("org/acme/clashing.txt"); + assertTrue(resources.hasMoreElements()); + URL resource = resources.nextElement(); + try (InputStream data = resource.openStream()) + { + assertEquals("correct contents of " + resource, "alpha", IO.toString(data)); + } + assertTrue(resources.hasMoreElements()); + resource = resources.nextElement(); + try (InputStream data = resource.openStream()) + { + assertEquals("correct contents of " + resource, "omega", IO.toString(data)); + } + assertFalse(resources.hasMoreElements()); + } + } diff --git a/jetty-webapp/src/test/webapp/WEB-INF/lib/alpha.jar b/jetty-webapp/src/test/webapp/WEB-INF/lib/alpha.jar new file mode 100644 index 00000000000..a26fb083a56 Binary files /dev/null and b/jetty-webapp/src/test/webapp/WEB-INF/lib/alpha.jar differ diff --git a/jetty-webapp/src/test/webapp/WEB-INF/lib/omega.jar b/jetty-webapp/src/test/webapp/WEB-INF/lib/omega.jar new file mode 100644 index 00000000000..b72fa753024 Binary files /dev/null and b/jetty-webapp/src/test/webapp/WEB-INF/lib/omega.jar differ