You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/03/06 03:15:48 UTC

[Bug 56223] New: ServletContext#setInitParameter(..) does not throw IllegalStateException after it's been initialized

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_89@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56223] ServletContext#setInitParameter(..) does not throw IllegalStateException after it's been initialized

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56223

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 OS|                            |All

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Thanks for the report.

This has been fixed in 7.0.x for 7.0.53 onwards and in 8.0.x for 8.0.4 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org