Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49181
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Apr 2010 23:26:20 +0000 (23:26 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Apr 2010 23:26:20 +0000 (23:26 +0000)
Patch provided by Pid

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

java/org/apache/catalina/core/ApplicationContext.java

index 2fbc249..4d7518d 100644 (file)
@@ -1256,24 +1256,29 @@ public class ApplicationContext
         // {@link ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)}
         // method of a {@link ServletContextListener} that was not declared
         // in web.xml, a web-fragment or annotated with {@link WebListener}.
-
+        
+        boolean match = false;
         if (t instanceof ServletContextAttributeListener ||
                 t instanceof ServletRequestListener ||
                 t instanceof ServletRequestAttributeListener ||
                 t instanceof HttpSessionAttributeListener) {
             context.addApplicationEventListener(t);
-            return;
+            match = true;
         }
         
         if (t instanceof HttpSessionListener) {
             context.addApplicationLifecycleListener(t);
+            match = true;
         }
         
         if (t instanceof ServletContextListener) {
             // TODO SERVLET3 - also need to check caller? spec isn't clear
             context.addApplicationLifecycleListener(t);
+            match = true;
         }
         
+        if (match) return;
+        
         throw new IllegalArgumentException(sm.getString(
                 "applicationContext.addListener.iae.wrongType",
                 t.getClass().getName()));