summaryrefslogtreecommitdiffstats
path: root/gerrit-launcher
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2011-07-07 23:23:35 -0400
committerShawn O. Pearce <sop@google.com>2011-10-27 20:11:32 -0700
commitae2ddeef6fa754c21a1d62cb6ca02950baecb907 (patch)
treebf50cd6cf14a35becf78c74f296ff6162ca88d91 /gerrit-launcher
parented73a583424a4f1f3138af8280b12708d4208c71 (diff)
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
Diffstat (limited to 'gerrit-launcher')
-rw-r--r--gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
index d9ea7d3e29..7f2007ef56 100644
--- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
+++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
@@ -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()]));
}