Author: markt Date: Sun Mar 23 20:44:13 2014 New Revision: 1580610 URL: http://svn.apache.org/r1580610 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/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1580598 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1580610&r1=1580609&r2=1580610&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Sun Mar 23 20:44:13 2014 @@ -139,6 +139,8 @@ public class WebappClassLoader private static final String JVN_THREAD_GROUP_SYSTEM = "system"; + private static final String SERVIVES_PREFIX = "META-INF/services/"; + static { JVM_THREAD_GROUP_NAMES.add(JVN_THREAD_GROUP_SYSTEM); JVM_THREAD_GROUP_NAMES.add("RMI Runtime"); @@ -3012,6 +3014,10 @@ public class WebappClassLoader int contentLength = -1; InputStream binaryStream = null; boolean isClassResource = path.endsWith(".class"); + boolean isCacheable = isClassResource; + if (!isCacheable) { + isCacheable = path.startsWith(SERVIVES_PREFIX); + } int jarFilesLength = jarFiles.length; int repositoriesLength = repositories.length; @@ -3214,19 +3220,22 @@ public class WebappClassLoader } /* 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 (binaryStream != null && - (isClassResource || fileNeedConvert)) { + (isCacheable || fileNeedConvert)) { byte[] binaryContent = new byte[contentLength]; Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1580610&r1=1580609&r2=1580610&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Mar 23 20:44:13 2014 @@ -107,6 +107,11 @@ just the file name to refer to refer to the JavaEE schema on which they are based. (markt) </add> + <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