From: markt Date: Tue, 31 Aug 2010 17:52:45 +0000 (+0000) Subject: Some Lifecycle clean-up X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b46c9dd1325b036df1efbe79679d26e9a3a754fd;p=tomcat7.0 Some Lifecycle clean-up git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@991274 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/core/ContainerBase.java b/java/org/apache/catalina/core/ContainerBase.java index e08e52557..404bc9b2a 100644 --- a/java/org/apache/catalina/core/ContainerBase.java +++ b/java/org/apache/catalina/core/ContainerBase.java @@ -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); } diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index 613fde526..7949751d6 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -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 diff --git a/java/org/apache/catalina/startup/LocalStrings.properties b/java/org/apache/catalina/startup/LocalStrings.properties index 58e50c3a1..b236ca8be 100644 --- a/java/org/apache/catalina/startup/LocalStrings.properties +++ b/java/org/apache/catalina/startup/LocalStrings.properties @@ -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 diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 48a999a1d..282cca8e1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -97,6 +97,11 @@ de-register the web application's Servlets with the MBean server. (markt) + + 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) +