You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2010/11/02 02:38:46 UTC

svn commit: r1029936 - in /geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina: connector/MapperListener.java core/ContainerBase.java

Author: xuhaihong
Date: Tue Nov  2 01:38:45 2010
New Revision: 1029936

URL: http://svn.apache.org/viewvc?rev=1029936&view=rev
Log:
GERONIMO-5665 destoryInternal method is called twice while destorying the children directly

Modified:
    geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/connector/MapperListener.java
    geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/core/ContainerBase.java

Modified: geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/connector/MapperListener.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/connector/MapperListener.java?rev=1029936&r1=1029935&r2=1029936&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/connector/MapperListener.java (original)
+++ geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/connector/MapperListener.java Tue Nov  2 01:38:45 2010
@@ -5,15 +5,15 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */ 
+ */
 package org.apache.catalina.connector;
 
 import org.apache.catalina.Container;
@@ -50,7 +50,7 @@ public class MapperListener implements C
      * Associated mapper.
      */
     private Mapper mapper = null;
-    
+
     /**
      * Associated connector
      */
@@ -99,10 +99,10 @@ public class MapperListener implements C
         // MBean listener won't be notified as those components will have
         // already registered their MBeans
         findDefaultHost();
-        
+
         Engine engine = (Engine) connector.getService().getContainer();
         engine.addContainerListener(this);
-        
+
         Container[] conHosts = engine.findChildren();
         for (Container conHost : conHosts) {
             Host host = (Host) conHost;
@@ -113,7 +113,7 @@ public class MapperListener implements C
             }
         }
     }
-        
+
 
     /**
      * Clean-up.
@@ -181,52 +181,52 @@ public class MapperListener implements C
             String hostName = wrapper.getParent().getParent().getName();
 
             String mapping = (String) event.getData();
-            
+
             mapper.removeWrapper(hostName, contextName, mapping);
         } else if (event.getType() == Context.ADD_WELCOME_FILE_EVENT) {
             // Handle dynamically adding welcome files
             Context context = (Context) event.getSource();
-            
+
             String hostName = context.getParent().getName();
 
             String contextName = context.getName();
             if ("/".equals(contextName)) {
                 contextName = "";
             }
-            
+
             String welcomeFile = (String) event.getData();
-            
+
             mapper.addWelcomeFile(hostName, contextName, welcomeFile);
         } else if (event.getType() == Context.REMOVE_WELCOME_FILE_EVENT) {
             // Handle dynamically removing welcome files
             Context context = (Context) event.getSource();
-            
+
             String hostName = context.getParent().getName();
 
             String contextName = context.getName();
             if ("/".equals(contextName)) {
                 contextName = "";
             }
-            
+
             String welcomeFile = (String) event.getData();
-            
+
             mapper.removeWelcomeFile(hostName, contextName, welcomeFile);
         } else if (event.getType() == Context.CLEAR_WELCOME_FILES_EVENT) {
             // Handle dynamically clearing welcome files
             Context context = (Context) event.getSource();
-            
+
             String hostName = context.getParent().getName();
 
             String contextName = context.getName();
             if ("/".equals(contextName)) {
                 contextName = "";
             }
-            
+
             mapper.clearWelcomeFiles(hostName, contextName);
         }
     }
 
-    
+
     // ------------------------------------------------------ Protected Methods
 
     private void findDefaultHost() {
@@ -238,14 +238,14 @@ public class MapperListener implements C
 
         if (defaultHost != null && defaultHost.length() >0) {
             Container[] containers = engine.findChildren();
-            
+
             for (Container container : containers) {
                 Host host = (Host) container;
                 if (defaultHost.equalsIgnoreCase(host.getName())) {
                     found = true;
                     break;
                 }
-                
+
                 String[] aliases = host.findAliases();
                 for (String alias : aliases) {
                     if (defaultHost.equalsIgnoreCase(alias)) {
@@ -264,17 +264,17 @@ public class MapperListener implements C
         }
     }
 
-    
+
     /**
      * Register host.
      */
     private void registerHost(Host host) {
-        
+
         String[] aliases = host.findAliases();
         mapper.addHost(host.getName(), aliases, host);
-        
+
         host.addContainerListener(this);
-        
+
         for (Container container : host.findChildren()) {
             registerContext((Context) container);
         }
@@ -291,7 +291,7 @@ public class MapperListener implements C
     private void unregisterHost(Host host) {
 
         String hostname = host.getName();
-        
+
         mapper.removeHost(hostname);
 
         if(log.isDebugEnabled())
@@ -299,7 +299,7 @@ public class MapperListener implements C
                     domain));
     }
 
-    
+
     /**
      * Unregister wrapper.
      */
@@ -312,13 +312,13 @@ public class MapperListener implements C
         String hostName = wrapper.getParent().getParent().getName();
 
         String[] mappings = wrapper.findMappings();
-        
+
         for (String mapping : mappings) {
             mapper.removeWrapper(hostName, contextName, mapping);
         }
     }
 
-    
+
     /**
      * Register context.
      */
@@ -329,7 +329,7 @@ public class MapperListener implements C
             contextName = "";
         }
         Container host = context.getParent();
-        
+
         javax.naming.Context resources = context.getResources();
         String[] welcomeFiles = context.findWelcomeFiles();
 
@@ -337,7 +337,7 @@ public class MapperListener implements C
                 welcomeFiles, resources);
 
         context.addContainerListener(this);
-       
+
         for (Container container : context.findChildren()) {
             registerWrapper((Wrapper) container);
         }
@@ -384,7 +384,7 @@ public class MapperListener implements C
             contextName = "";
         }
         String hostName = wrapper.getParent().getParent().getName();
-        
+
         String[] mappings = wrapper.findMappings();
 
         for (String mapping : mappings) {
@@ -413,7 +413,7 @@ public class MapperListener implements C
             } else if (obj instanceof Host) {
                 registerHost((Host) obj);
             }
-        } else if (event.getType() == Lifecycle.BEFORE_STOP_EVENT) {
+        } else if (event.getType() == Lifecycle.AFTER_STOP_EVENT) {
             Object obj = event.getSource();
             if (obj instanceof Wrapper) {
                 unregisterWrapper((Wrapper) obj);
@@ -427,7 +427,7 @@ public class MapperListener implements C
 
     /**
      * Remove this mapper from the container and all child containers
-     * 
+     *
      * @param container
      */
     private void removeListeners(Container container) {

Modified: geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/core/ContainerBase.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/core/ContainerBase.java?rev=1029936&r1=1029935&r2=1029936&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/core/ContainerBase.java (original)
+++ geronimo/external/trunk/tomcat-parent-7.0.0/catalina/src/main/java/org/apache/catalina/core/ContainerBase.java Tue Nov  2 01:38:45 2010
@@ -1096,7 +1096,11 @@ public abstract class ContainerBase exte
 
         // Required if the child is destroyed directly.
         if (parent != null) {
-            parent.removeChild(this);
+            if (parent instanceof ContainerBase) {
+                ((ContainerBase) parent).removeChildInternal(this);
+            } else {
+                parent.removeChild(this);
+            }
         } else {
             // Stop the Valves in our pipeline (including the basic), if any
             if (pipeline instanceof Lifecycle) {
@@ -1104,7 +1108,7 @@ public abstract class ContainerBase exte
             }
             // Remove children now this container is being destroyed
             for (Container child : findChildren()) {
-                removeChildInternal(child);
+                removeChild(child);
             }
             super.destroyInternal();
         }