Fix memory leak on context stop
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 24 Aug 2010 21:08:34 +0000 (21:08 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 24 Aug 2010 21:08:34 +0000 (21:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@988729 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/ContextConfig.java
java/org/apache/catalina/startup/LocalStrings.properties
webapps/docs/changelog.xml

index c142da9..613fde5 100644 (file)
@@ -58,6 +58,7 @@ import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Valve;
@@ -299,6 +300,7 @@ public class ContextConfig
      *
      * @param event The lifecycle event that has occurred
      */
+    @Override
     public void lifecycleEvent(LifecycleEvent event) {
 
         // Identify the context we are associated with
@@ -929,6 +931,12 @@ public class ContextConfig
         Container[] children = context.findChildren();
         for (i = 0; i < children.length; i++) {
             context.removeChild(children[i]);
+            try {
+                children[i].destroy();
+            } catch (LifecycleException e) {
+                log.warn(sm.getString("contentConfig.destroyChildFailed",
+                        children[1].getName(), context.getName()), e);
+            }
         }
 
         // Removing application parameters
index b236ca8..58e50c3 100644 (file)
@@ -35,6 +35,7 @@ contextConfig.defaultError=Error processed default web.xml named {0} at {1}
 contextConfig.defaultMissing=No global web.xml found
 contextConfig.defaultPosition=Occurred at line {0} column {1}
 contextConfig.destroy=ContextConfig: Destroying
+contentConfig.destroyChildFailed=Failed to destroy child [{0}] of context [{1}]
 contextConfig.fileUrl=Unable to create a File object from the URL [{0}]
 contextConfig.fixDocBase=Exception fixing docBase for context [{0}] 
 contextConfig.init=ContextConfig: Initializing
index a855ddf..0f99d5e 100644 (file)
         CSRF prevention filter did not correctly handle URLs that used anchors.
         (markt)
       </fix>
+      <fix>
+        Fix memory leak on web application stopped caused by failed to
+        de-register the web application's Servlets with the MBean server.
+        (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">