luehe       2005/02/17 09:55:24

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
  Log:
  Removed potential WebappClassLoader leak.
  
  Consider the following example scenario:
  
  - Servlet class references RequestDispatcher.
  
  - Servlet is loaded. Any of the symbols referenced will be
    resolved lazily.
  
  - Servlet is invoked. Thread's context classloader has been set to the
    servlet's WebappClassLoader.
  
  - org.apache.catalina.core.ApplicationDispatcher is loaded, and its
    static "log" variable is initialized as follows:
  
      private static Log log = LogFactory.getLog(ApplicationDispatcher.class);
  
  - LogFactory.getLog() causes the context classloader (which corresponds
    to the WebappClassLoader) to be cached in its static "factories"
    Hashtable, as follows:
  
      if (classLoader != null && factory != null)
          factories.put(classLoader, factory);
  
  Right now, this classloader is never removed from this Hashtable when the
  webapp is stopped.
  
  Depending on number of deployed webapps and their servlets' execution
  paths, different Catalina classes will be loaded on different servlet
  invocation threads, and the classes' "log" initialization will cause
  the threads' context classloaders to be cached in LogFactory and never
  released from it.
  
  This patch should fix the issue.
  
  Let me know if you see any problems.
  
  Revision  Changes    Path
  1.163     +4 -1      
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.162
  retrieving revision 1.163
  diff -u -r1.162 -r1.163
  --- StandardContext.java      9 Feb 2005 12:20:40 -0000       1.162
  +++ StandardContext.java      17 Feb 2005 17:55:24 -0000      1.163
  @@ -4236,6 +4236,9 @@
           // Mark this application as unavailable while we shut down
           setAvailable(false);
   
  +        // Remove our classloader from LogFactory's 'factories' cache
  +        LogFactory.release(getLoader().getClassLoader());
  +
           // Binding thread
           ClassLoader oldCCL = bindThread();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to