You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/03/06 17:19:45 UTC
svn commit: r1574943 - in /tomcat/trunk:
java/org/apache/catalina/core/ApplicationContext.java
java/org/apache/catalina/core/LocalStrings.properties
test/org/apache/catalina/core/TestApplicationContext.java
webapps/docs/changelog.xml
Author: markt
Date: Thu Mar 6 16:19:44 2014
New Revision: 1574943
URL: http://svn.apache.org/r1574943
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56223
Throw an IllegalStateException if a call is made to ServletContext.setInitParameter() after the ServletContext has been initialized
Modified:
tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java
tomcat/trunk/webapps/docs/changelog.xml
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=1574943&r1=1574942&r2=1574943&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Thu Mar 6 16:19:44 2014
@@ -1200,6 +1200,12 @@ public class ApplicationContext
@Override
public boolean setInitParameter(String name, String value) {
+ if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
+ throw new IllegalStateException(
+ sm.getString("applicationContext.setInitParam.ise",
+ getContextPath()));
+ }
+
return parameters.putIfAbsent(name, value) == null;
}
Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1574943&r1=1574942&r2=1574943&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Thu Mar 6 16:19:44 2014
@@ -29,6 +29,7 @@ applicationContext.resourcePaths.iae=Pat
applicationContext.role.iae=An individual role to declare for context [{0}] may not be null nor the empty string
applicationContext.roles.iae=Array of roles to declare for context [{0}] cannot be null
applicationContext.setAttribute.namenull=Name cannot be null
+applicationContext.setInitParam.ise=Initialization parameters can not be set after the context has been initialized
applicationContext.setSessionTracking.ise=The session tracking modes for context {0} cannot be set whilst the context is running
applicationContext.setSessionTracking.iae.invalid=The session tracking mode {0} requested for context {1} is not supported by that context
applicationContext.setSessionTracking.iae.ssl=The session tracking modes requested for context {0} included SSL and at least one other mode. SSL may not be configured with other modes.
Modified: tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java?rev=1574943&r1=1574942&r2=1574943&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java Thu Mar 6 16:19:44 2014
@@ -157,4 +157,11 @@ public class TestApplicationContext exte
return standardContext.getServletContext();
}
+
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetInitParameter() throws Exception {
+ getTomcatInstance().start();
+ getServletContext().setInitParameter("name", "value");
+ }
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1574943&r1=1574942&r2=1574943&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Mar 6 16:19:44 2014
@@ -128,6 +128,11 @@
<bug>56199</bug>: Restore validateXml option for JspC which determines
if web.xml will be parsed with a validating parser. (markt)
</fix>
+ <fix>
+ <bug>56223</bug>: Throw an <code>IllegalStateException</code> if a call
+ is made to <code>ServletContext.setInitParameter()</code> after the
+ ServletContext has been initialized. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org