Author: markt
Date: Sun Mar 23 20:33:13 2014
New Revision: 1580598

URL: http://svn.apache.org/r1580598
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56293
Cache resources loaded by the class loader from /META-INF/services/ for better 
performance for repeated look ups.

Modified:
    tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1580598&r1=1580597&r2=1580598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Sun Mar 
23 20:33:13 2014
@@ -136,6 +136,7 @@ public class WebappClassLoader extends U
     private static final String JVN_THREAD_GROUP_SYSTEM = "system";
 
     private static final String CLASS_FILE_SUFFIX = ".class";
+    private static final String SERVIVES_PREFIX = "/META-INF/services/";
 
     static {
         JVM_THREAD_GROUP_NAMES.add(JVN_THREAD_GROUP_SYSTEM);
@@ -2537,6 +2538,10 @@ public class WebappClassLoader extends U
         }
 
         boolean isClassResource = path.endsWith(CLASS_FILE_SUFFIX);
+        boolean isCacheable = isClassResource;
+        if (!isCacheable) {
+             isCacheable = path.startsWith(SERVIVES_PREFIX);
+        }
 
         WebResource resource = null;
 
@@ -2558,18 +2563,21 @@ public class WebappClassLoader extends U
         }
 
         /* Only cache the binary content if there is some content
-         * available and either:
+         * available one of the following is true:
          * a) It is a class file since the binary content is only cached
          *    until the class has been loaded
          *    or
          * b) The file needs conversion to address encoding issues (see
          *    below)
+         *    or
+         * c) The resource is a service provider configuration file located
+         *    under META=INF/services
          *
          * In all other cases do not cache the content to prevent
          * excessive memory usage if large resources are present (see
          * https://issues.apache.org/bugzilla/show_bug.cgi?id=53081).
          */
-        if (isClassResource || fileNeedConvert) {
+        if (isCacheable || fileNeedConvert) {
             byte[] binaryContent = resource.getContent();
             if (binaryContent != null) {
                  if (fileNeedConvert) {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1580598&r1=1580597&r2=1580598&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sun Mar 23 20:33:13 2014
@@ -55,6 +55,11 @@
         Allow web applications to package tomcat-jdbc.jar and their JDBC driver
         of choice in the web application. (markt)
       </fix>
+      <fix>
+        <bug>56293</bug>: Cache resources loaded by the class loader from
+        <code>/META-INF/services/</code> for better performance for repeated
+        look ups. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to