Some Lifecycle clean-up
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 31 Aug 2010 17:52:45 +0000 (17:52 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 31 Aug 2010 17:52:45 +0000 (17:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@991274 13f79535-47bb-0310-9956-ffa450edef68

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

index e08e525..404bc9b 100644 (file)
@@ -956,7 +956,13 @@ public abstract class ContainerBase extends LifecycleMBeanBase
         
         fireContainerEvent(REMOVE_CHILD_EVENT, child);
         
-        // child.setParent(null);
+        // Set child's parent to null to prevent a loop
+        child.setParent(null);
+        try {
+            child.destroy();
+        } catch (LifecycleException e) {
+            log.error("ContainerBase.removeChild: destroy: ", e);
+        }
 
     }
 
@@ -1091,9 +1097,10 @@ public abstract class ContainerBase extends LifecycleMBeanBase
 
         // Remove children now this container is being destroyed
         for (Container child : findChildren()) {
-            child.destroy();
+            removeChild(child);
         }
 
+        // Required if the child is destroyed directly.
         if (parent != null) {
             parent.removeChild(this);
         }
index 613fde5..7949751 100644 (file)
@@ -58,7 +58,6 @@ 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;
@@ -931,12 +930,6 @@ 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 58e50c3..b236ca8 100644 (file)
@@ -35,7 +35,6 @@ 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 48a999a..282cca8 100644 (file)
         de-register the web application's Servlets with the MBean server.
         (markt)
       </fix>
+      <update>
+        More tweaks to the Lifecycle refactoring to ensure that when a component
+        is being destroyed, the destroy method is only called once on each
+        child component. (markt) 
+      </update>
     </changelog>
   </subsection>
   <subsection name="Coyote">