Author: markt
Date: Wed May 12 10:24:00 2010
New Revision: 943432
URL: http://svn.apache.org/viewvc?rev=943432&view=rev
Log:
Fix remainder of https://issues.apache.org/bugzilla/show_bug.cgi?id=49181
Add additional check to prevent adding Servlet context listeners once the calls
to the Servlet Context listeners start
Modified:
tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=943432&r1=943431&r2=943432&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Wed May
12 10:24:00 2010
@@ -184,6 +184,13 @@ public class ApplicationContext
private Set<SessionTrackingMode> defaultSessionTrackingModes = null;
private Set<SessionTrackingMode> supportedSessionTrackingModes = null;
+ /**
+ * Flag that indicates if a new {...@link ServletContextListener} may be
added
+ * to the application. Once the first {...@link ServletContextListener} is
+ * called, not more may be added.
+ */
+ private boolean newServletContextListenerAllowed = true;
+
// --------------------------------------------------------- Public Methods
@@ -1275,8 +1282,8 @@ public class ApplicationContext
}
if (t instanceof HttpSessionListener
- || t instanceof ServletContextListener) {
- // TODO SERVLET3 - if ServletContextListener then also need to
check caller? spec isn't clear
+ || (t instanceof ServletContextListener &&
+ newServletContextListenerAllowed)) {
context.addApplicationLifecycleListener(t);
match = true;
}
@@ -1471,6 +1478,10 @@ public class ApplicationContext
}
+ protected void setNewServletContextListenerAllowed(boolean allowed) {
+ this.newServletContextListenerAllowed = allowed;
+ }
+
// -------------------------------------------------------- Private Methods
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=943432&r1=943431&r2=943432&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Wed May 12
10:24:00 2010
@@ -4266,6 +4266,10 @@ public class StandardContext extends Con
if (getLogger().isDebugEnabled())
getLogger().debug("Sending application start events");
+ // Ensure context is not null
+ getServletContext();
+ context.setNewServletContextListenerAllowed(false);
+
Object instances[] = getApplicationLifecycleListeners();
if (instances == null)
return (ok);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]