https://bz.apache.org/bugzilla/show_bug.cgi?id=59866

            Bug ID: 59866
           Summary: Tomcat incorrectly scans
                    WEB-INF/classes/META-INF/resources for classes
           Product: Tomcat 7
           Version: 7.0.70
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: caij...@apache.org

During startup, Tomcat incorrectly scans the WEB-INF/classes/META-INF/resources
folder to find classses, which also presents a performance penalty.

This happens in two situations:

1. When Tomcat tries to find classes to cache. The code in problem is at Line
2275 in [1]. It calls the webapp classloader's getResourceAsStream() method and
eventually ends up doing a lookup in WEB-INF/classes/META-INF/resources for
many Java class.

2. When Tomcat tries to load some classes using the webapp classloader, the
classloader's findClassInternal() calls its findResourceInternal() method,
which may do a lookup in its repository (aka WEB-INF/classes), see Line 3291 in
[2].

The code actually does the lookup in the WEB-INF/classes/META-INF/resources is
at Line 502 in [3]. The above situations can be easily observed by setting a
breakpoint at this line and then start tomcat in debug mode with all the
default configurations (addWebinfClassesResources is false, though even if it's
set to true the above behavior is wrong).

This same issue may exist in Tomcat 8 and onwards as well.

[1]
http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_70/java/org/apache/catalina/startup/ContextConfig.java
[2]
http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_70/java/org/apache/catalina/loader/WebappClassLoaderBase.java
[3]
http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_70/java/org/apache/naming/resources/BaseDirContext.java

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

Reply via email to