Author: kkolinko Date: Mon Jan 18 02:45:49 2016 New Revision: 1725165 URL: http://svn.apache.org/viewvc?rev=1725165&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=58766#c4 Slightly improve performance of scanning a directory: check the file name first, as file.canRead() is an I/O operation.
Add debug logging. Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1725165&r1=1725164&r2=1725165&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Mon Jan 18 02:45:49 2016 @@ -1927,8 +1927,15 @@ public class ContextConfig implements Li WebResource[] webResources = webResource.getWebResourceRoot().listResources( webResource.getWebappPath()); - for (WebResource r : webResources) { - processAnnotationsWebResource(r, fragment, handlesTypesOnly); + if (webResources.length > 0) { + if (log.isDebugEnabled()) { + log.debug(sm.getString( + "contextConfig.processAnnotationsWebDir.debug", + webResource.getURL())); + } + for (WebResource r : webResources) { + processAnnotationsWebResource(r, fragment, handlesTypesOnly); + } } } else if (webResource.isFile() && webResource.getName().endsWith(".class")) { @@ -1971,6 +1978,11 @@ public class ContextConfig implements Li boolean handlesTypesOnly) { try (Jar jar = JarFactory.newInstance(url)) { + if (log.isDebugEnabled()) { + log.debug(sm.getString( + "contextConfig.processAnnotationsJar.debug", url)); + } + jar.nextEntry(); String entryName = jar.getEntryName(); while (entryName != null) { @@ -2002,12 +2014,16 @@ public class ContextConfig implements Li // Returns null if directory is not readable String[] dirs = file.list(); if (dirs != null) { + if (log.isDebugEnabled()) { + log.debug(sm.getString( + "contextConfig.processAnnotationsDir.debug", file)); + } for (String dir : dirs) { processAnnotationsFile( new File(file,dir), fragment, handlesTypesOnly); } } - } else if (file.canRead() && file.getName().endsWith(".class")) { + } else if (file.getName().endsWith(".class") && file.canRead()) { try (FileInputStream fis = new FileInputStream(file)) { processAnnotationsStream(fis, fragment, handlesTypesOnly); } catch (IOException e) { Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=1725165&r1=1725164&r2=1725165&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Mon Jan 18 02:45:49 2016 @@ -55,6 +55,9 @@ contextConfig.jndiUrlNotDirContextConn=T contextConfig.jspFile.error=JSP file {0} must start with a ''/' contextConfig.jspFile.warning=WARNING: JSP file {0} must start with a ''/'' in Servlet 2.4 contextConfig.missingRealm=No Realm has been configured to authenticate against +contextConfig.processAnnotationsDir.debug=Scanning directory for class files with annotations [{0}] +contextConfig.processAnnotationsJar.debug=Scanning jar file for class files with annotations [{0}] +contextConfig.processAnnotationsWebDir.debug=Scanning web application directory for class files with annotations [{0}] contextConfig.resourceJarFail=Failed to process JAR found at URL [{0}] for static resources to be included in context with name [{1}] contextConfig.role.auth=Security role name {0} used in an <auth-constraint> without being defined in a <security-role> contextConfig.role.link=Security role name {0} used in a <role-link> without being defined in a <security-role> Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1725165&r1=1725164&r2=1725165&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Mon Jan 18 02:45:49 2016 @@ -180,6 +180,11 @@ it is read-only. (kkolinko) </fix> <fix> + <bug>58766</bug>: Make skipping non-class files during annotation + scanning faster by checking the file name first. Improve debug logging. + (kkolinko) + </fix> + <fix> <bug>58836</bug>: Correctly merge query string parameters when processing a forwarded request where the target includes a query string that contains a parameter with no value. (markt/kkolinko) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org