https://bz.apache.org/bugzilla/show_bug.cgi?id=58751

            Bug ID: 58751
           Summary: Strange behaviour after calling sendError when an
                    async request times out
           Product: Tomcat 8
           Version: 8.0.30
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: awilkin...@pivotal.io

Created attachment 33359
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33359&action=edit
Sample the reproduces the problem

This problem's probably most easily described with the attached sample. There's
a servlet mapped to /error and a custom error page registered with /error as
it's location. Another servlet is mapped to /timeout. It deliberately allows an
async request to timeout and then calls response.sendError(503).

My expectation is that this will result in the request being routed to the
error servlet and that, as a result, a 503 response will be returned with
"Error!" in the body.

The actual outcome is that a 500 response is returned with "Error!" in the
body:

$ curl -i localhost:8080/timeout
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Length: 7
Date: Thu, 17 Dec 2015 20:49:00 GMT
Connection: close

Error!

And the following severe message and exception are logged:

SEVERE: Exception Processing ErrorPage[errorCode=0, location=/error]
java.lang.IllegalStateException: Cannot forward after response has been
committed
    at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:327)
    at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:317)
    at
org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:445)
    at
org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:304)
    at
org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399)
    at
org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:451)
    at
org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:293)
    at
org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1716)
    at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:650)
    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

-- 
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

Reply via email to