https://issues.apache.org/bugzilla/show_bug.cgi?id=56223
Bug ID: 56223 Summary: ServletContext#setInitParameter(..) does not throw IllegalStateException after it's been initialized Product: Tomcat 8 Version: 8.0.3 Hardware: PC Status: NEW Severity: normal Priority: P2 Component: Specification APIs Assignee: dev@tomcat.apache.org Reporter: sotodel...@hotmail.com Created attachment 31369 --> https://issues.apache.org/bugzilla/attachment.cgi?id=31369&action=edit .war with single Servlet The Java EE javadoc for ServletContext#setInitParameter(String, String), here: http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContext.html#setInitParameter(java.lang.String, java.lang.String), states that the method should throw an IllegalStateException if the ServletContext has already been initialized. Once a Servlet is ready to handle requests, the ServletContext must have been initialized. However, no exception is thrown if you try to invoke the method in an HttpServlet's doGet(..). Steps to reproduce: 1) Add an HttpServlet that invokes the method in its doGet(..) method @WebServlet(urlPatterns = "/init") public class InitParameterServlet extends HttpServlet { private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); context.setInitParameter("init-param", "value"); } } 2) Send an HTTP GET request to (the appropriate) 'http://localhost:8080/context/init`. Actual results: No exception is thrown. Server sends back 200 OK. Expected results: An exception should have been thrown. Server should have sent back 500 status code. Tomcat 8.0.3 (and 7.0.42) and Windows 7 Additional information: You can also try calling, for example, the addFilter(..) method which will fail stating that the ServletContext is already initialized. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org