Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50169
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Nov 2010 12:29:40 +0000 (12:29 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Nov 2010 12:29:40 +0000 (12:29 +0000)
Ensure that when a Container is started that it doesn't try and register with the mapper unless its parent has already started.
Patch provided by Eiji Takahashi.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1033912 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardContext.java
java/org/apache/catalina/core/StandardWrapper.java
webapps/docs/changelog.xml

index 76880ab..569efe1 100644 (file)
@@ -3033,8 +3033,8 @@ public class StandardContext extends ContainerBase
             welcomeFiles = results;
         }
         postWelcomeFiles();
-        fireContainerEvent(ADD_WELCOME_FILE_EVENT, name);
-
+        if(this.getState().equals(LifecycleState.STARTED))
+            fireContainerEvent(ADD_WELCOME_FILE_EVENT, name);
     }
 
 
@@ -4127,7 +4127,8 @@ public class StandardContext extends ContainerBase
 
         // Inform interested listeners
         postWelcomeFiles();
-        fireContainerEvent(REMOVE_WELCOME_FILE_EVENT, name);
+        if(this.getState().equals(LifecycleState.STARTED))
+            fireContainerEvent(REMOVE_WELCOME_FILE_EVENT, name);
 
     }
 
index 7bd1284..299209b 100644 (file)
@@ -53,6 +53,7 @@ import org.apache.catalina.Globals;
 import org.apache.catalina.InstanceEvent;
 import org.apache.catalina.InstanceListener;
 import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.mbeans.MBeanUtils;
 import org.apache.catalina.security.SecurityUtil;
@@ -737,7 +738,8 @@ public class StandardWrapper extends ContainerBase
         synchronized (mappings) {
             mappings.add(mapping);
         }
-        fireContainerEvent(ADD_MAPPING_EVENT, mapping);
+        if(parent.getState().equals(LifecycleState.STARTED))
+            fireContainerEvent(ADD_MAPPING_EVENT, mapping);
 
     }
 
@@ -1198,7 +1200,8 @@ public class StandardWrapper extends ContainerBase
         synchronized (mappings) {
             mappings.remove(mapping);
         }
-        fireContainerEvent(REMOVE_MAPPING_EVENT, mapping);
+        if(parent.getState().equals(LifecycleState.STARTED))
+            fireContainerEvent(REMOVE_MAPPING_EVENT, mapping);
 
     }
 
index 2938dd7..2c49144 100644 (file)
         ensure that <code>Context</code> objects are only destroyed once.
         (markt)
       </fix>
+      <fix>
+        <bug>50169</bug>: Ensure that when a Container is started that it
+        doesn&apos;t try and register with the mapper unless its parent has
+        already started. Patch provided by Eiji Takahashi. (markt)
+      </fix>
       <add>
         <bug>50222</bug>: Modify memory leak prevention code so it pins the
         system class loader in memory rather than than the common class loader,