Add listener before child is added else listener won't get called on first load
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 12 Feb 2010 19:15:32 +0000 (19:15 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 12 Feb 2010 19:15:32 +0000 (19:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@909563 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardHost.java

index 870df74..1c48bcd 100644 (file)
@@ -578,15 +578,16 @@ public class StandardHost
     @Override
     public void addChild(Container child) {
 
+        if (child instanceof Lifecycle) {
+            ((Lifecycle) child).addLifecycleListener(
+                    new MemoryLeakTrackingListener());
+        }
+
         if (!(child instanceof Context))
             throw new IllegalArgumentException
                 (sm.getString("standardHost.notContext"));
         super.addChild(child);
 
-        if (child instanceof Lifecycle) {
-            ((Lifecycle) child).addLifecycleListener(
-                    new MemoryLeakTrackingListener());
-        }
     }