tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1742081 - in /tomcat/tc8.5.x/trunk: ./ java/org/apache/tomcat/JarScannerCallback.java java/org/apache/tomcat/util/scan/StandardJarScanner.java
Date Tue, 03 May 2016 10:26:47 GMT
Author: markt
Date: Tue May  3 10:26:47 2016
New Revision: 1742081

URL: http://svn.apache.org/viewvc?rev=1742081&view=rev
Log:
Traverse StandardJarScanner's class loader hierarchy once rather than once per scan. Marginally
improves start times.
Javadoc fixes
Line length

Modified:
    tomcat/tc8.5.x/trunk/   (props changed)
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/JarScannerCallback.java
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java

Propchange: tomcat/tc8.5.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May  3 10:26:47 2016
@@ -1 +1 @@
-/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818,1739975,1740131,1740324,1740465,1740495,1740508-1740509,1740520,1740535,1740707,1740803,1740810,1740969,1740980,1740991,1740997,1741015,1741033,1741036,1741058,1741060,1741080,1741147,1741159,1741164,1741173,1741181,1741190,1741197,1741202,1741208,1741213,1741221,1741225,1741232,1741409,1741501
+/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818,1739975,1740131,1740324,1740465,1740495,1740508-1740509,1740520,1740535,1740707,1740803,1740810,1740969,1740980,1740991,1740997,1741015,1741033,1741036,1741058,1741060,1741080,1741147,1741159,1741164,1741173,1741181,1741190,1741197,1741202,1741208,1741213,1741221,1741225,1741232,1741409,1741501,1741677
 ,1741892,1741896

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/JarScannerCallback.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/JarScannerCallback.java?rev=1742081&r1=1742080&r2=1742081&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/JarScannerCallback.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/JarScannerCallback.java Tue May  3 10:26:47
2016
@@ -27,8 +27,8 @@ import java.net.JarURLConnection;
 public interface JarScannerCallback {
 
     /**
-     * A JAR was found (probably packaged in a WAR) and may be accessed for
-     * further processing via the provided URL connection.
+     * A JAR was found and may be accessed for further processing via the
+     * provided URL connection.
      *
      * @param urlConn    The connection to the identified JAR
      * @param webappPath The path, if any, to the JAR within the web application
@@ -42,11 +42,10 @@ public interface JarScannerCallback {
             throws IOException;
 
     /**
-     * A JAR was found (probably in an unpacked WAR or possibly elsewhere on the
-     * class path) and may be accessed for further processing via the provided
-     * file.
+     * A directory was found that is to be treated as an unpacked JAR. The
+     * directory may be accessed for further processing via the provided file.
      *
-     * @param file       The file for the identified JAR.
+     * @param file       The directory containing the unpacked JAR.
      * @param webappPath The path, if any, to the file within the web
      *                       application
      * @param isWebapp   Indicates if the JAR was found within a web

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java?rev=1742081&r1=1742080&r2=1742081&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java Tue May
 3 10:26:47 2016
@@ -23,6 +23,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLConnection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -60,8 +61,21 @@ public class StandardJarScanner implemen
     /**
      * The string resources for this package.
      */
-    private static final StringManager sm =
-        StringManager.getManager(Constants.Package);
+    private static final StringManager sm = StringManager.getManager(Constants.Package);
+
+    private static final Set<ClassLoader> CLASSLOADER_HIERARCHY;
+
+    static {
+        Set<ClassLoader> cls = new HashSet<>();
+
+        ClassLoader cl = StandardJarScanner.class.getClassLoader();
+        while (cl != null) {
+            cls.add(cl);
+            cl = cl.getParent();
+        }
+
+        CLASSLOADER_HIERARCHY = Collections.unmodifiableSet(cls);
+    }
 
     /**
      * Controls the classpath scanning extension.
@@ -243,8 +257,7 @@ public class StandardJarScanner implemen
                                         getJarScanFilter().check(scanType,
                                                 cpe.getName())) {
                             if (log.isDebugEnabled()) {
-                                log.debug(sm.getString(
-                                        "jarScan.classloaderJarScan", urls[i]));
+                                log.debug(sm.getString("jarScan.classloaderJarScan", urls[i]));
                             }
                             String webappPath = null;
                             if (urls[i].equals(webInfURL)) {
@@ -253,16 +266,12 @@ public class StandardJarScanner implemen
                             try {
                                 process(scanType, callback, urls[i], webappPath, isWebapp);
                             } catch (IOException ioe) {
-                                log.warn(sm.getString(
-                                        "jarScan.classloaderFail", urls[i]),
-                                                ioe);
+                                log.warn(sm.getString("jarScan.classloaderFail", urls[i]),
ioe);
                             }
                         } else {
                             // JAR / directory has been skipped
                             if (log.isTraceEnabled()) {
-                                log.trace(sm.getString(
-                                        "jarScan.classloaderJarNoScan",
-                                        urls[i]));
+                                log.trace(sm.getString("jarScan.classloaderJarNoScan", urls[i]));
                             }
                         }
                     }
@@ -287,16 +296,8 @@ public class StandardJarScanner implemen
      *   the system class loader is not an application class loader
      *   the bootstrap class loader is not an application class loader
      */
-    private boolean isWebappClassLoader(ClassLoader classLoader) {
-        ClassLoader nonWebappLoader = StandardJarScanner.class.getClassLoader();
-
-        while (nonWebappLoader != null) {
-            if (nonWebappLoader == classLoader) {
-                return false;
-            }
-            nonWebappLoader = nonWebappLoader.getParent();
-        }
-        return true;
+    private static boolean isWebappClassLoader(ClassLoader classLoader) {
+        return !CLASSLOADER_HIERARCHY.contains(classLoader);
     }
 
 



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


Mime
View raw message