Author: markt
Date: Sat Oct  3 19:36:01 2009
New Revision: 821397

URL: http://svn.apache.org/viewvc?rev=821397&view=rev
Log:
Ignore duplicate entries on the classpath.
Patch could be smaller but change variable name to make new behaviour clear

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java?rev=821397&r1=821396&r2=821397&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Sat 
Oct  3 19:36:01 2009
@@ -21,7 +21,8 @@
 
 import java.io.File;
 import java.net.URL;
-import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 import org.apache.catalina.loader.StandardClassLoader;
 import org.apache.juli.logging.Log;
@@ -84,7 +85,7 @@
             log.debug("Creating new class loader");
 
         // Construct the "class path" for this class loader
-        ArrayList<URL> list = new ArrayList<URL>();
+        Set<URL> set = new LinkedHashSet<URL>();
 
         // Add unpacked directories
         if (unpacked != null) {
@@ -96,7 +97,7 @@
                 URL url = file.toURI().toURL();
                 if (log.isDebugEnabled())
                     log.debug("  Including directory " + url);
-                list.add(url);
+                set.add(url);
             }
         }
 
@@ -116,13 +117,13 @@
                     if (log.isDebugEnabled())
                         log.debug("  Including jar file " + 
file.getAbsolutePath());
                     URL url = file.toURI().toURL();
-                    list.add(url);
+                    set.add(url);
                 }
             }
         }
 
         // Construct the class loader itself
-        URL[] array = list.toArray(new URL[list.size()]);
+        URL[] array = set.toArray(new URL[set.size()]);
         StandardClassLoader classLoader = null;
         if (parent == null)
             classLoader = new StandardClassLoader(array);
@@ -157,7 +158,7 @@
             log.debug("Creating new class loader");
 
         // Construct the "class path" for this class loader
-        ArrayList<URL> list = new ArrayList<URL>();
+        Set<URL> set = new LinkedHashSet<URL>();
 
         if (locations != null && types != null && locations.length == 
types.length) {
             for (int i = 0; i < locations.length; i++)  {
@@ -166,7 +167,7 @@
                     URL url = new URL(location);
                     if (log.isDebugEnabled())
                         log.debug("  Including URL " + url);
-                    list.add(url);
+                    set.add(url);
                 } else if ( types[i] == IS_DIR ) {
                     File directory = new File(location);
                     directory = new File(directory.getCanonicalPath());
@@ -176,7 +177,7 @@
                     URL url = directory.toURI().toURL();
                     if (log.isDebugEnabled())
                         log.debug("  Including directory " + url);
-                    list.add(url);
+                    set.add(url);
                 } else if ( types[i] == IS_JAR ) {
                     File file=new File(location);
                     file = new File(file.getCanonicalPath());
@@ -185,7 +186,7 @@
                     URL url = file.toURI().toURL();
                     if (log.isDebugEnabled())
                         log.debug("  Including jar file " + url);
-                    list.add(url);
+                    set.add(url);
                 } else if ( types[i] == IS_GLOB ) {
                     File directory=new File(location);
                     if (!directory.exists() || !directory.isDirectory() ||
@@ -207,14 +208,14 @@
                             log.debug("    Including glob jar file "
                                 + file.getAbsolutePath());
                         URL url = file.toURI().toURL();
-                        list.add(url);
+                        set.add(url);
                     }
                 }
             }
         }
 
         // Construct the class loader itself
-        URL[] array = list.toArray(new URL[list.size()]);
+        URL[] array = set.toArray(new URL[set.size()]);
         if (log.isDebugEnabled())
             for (int i = 0; i < array.length; i++) {
                 log.debug("  location " + i + " is " + array[i]);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to