Sort the jar files from the war before adding to classpath.
Currently, the order they are inserted onto the classpath depends on directory iteration order of the WEB-INF directory at war-file building time. On some filesystems that is alphabetical, and on some filesystems, it is completely arbitrary. On the second kind of filesystem, gerrit-patch-jgit can randomly end up on the classpath *after* jgit itself, thus causing it to not be loaded. Change-Id: I4ee9b22cbb93405e033f6f6bda9da1dd87b3419f
This commit is contained in:

committed by
Shawn O. Pearce

parent
ed73a58342
commit
ae2ddeef6f
@@ -31,6 +31,8 @@ import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
@@ -235,6 +237,12 @@ public final class GerritLauncher {
|
||||
if (jars.isEmpty()) {
|
||||
return GerritLauncher.class.getClassLoader();
|
||||
}
|
||||
Collections.sort(jars, new Comparator<URL>() {
|
||||
public int compare(URL o1, URL o2) {
|
||||
return o1.toString().compareTo(o2.toString());
|
||||
}
|
||||
});
|
||||
|
||||
return new URLClassLoader(jars.toArray(new URL[jars.size()]));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user