Bug 54123 - servlet 3.0 spec violation in async timeout processing
servlet 3.0 spec violation in async timeout processing
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
trunk
PC Linux
: P2 major (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-11-09 10:30 UTC by Eugene Chung (TmaxSoft)
Modified: 2012-11-12 01:26 UTC (History)
0 users



Attachments
test war file within java source (2.44 KB, application/x-webarchive)
2012-11-09 10:30 UTC, Eugene Chung (TmaxSoft)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Chung (TmaxSoft) 2012-11-09 10:30:48 UTC
Created attachment 29575 [details]
test war file within java source

Servlet 3.0 Spec. says that


2.3.3.3 Asynchronous processing

...

In the event that an asynchronous operation times out, the container must run 
through the following steps: 
■ Invoke the AsyncListener.onTimeout method on all the AsyncListener 
instances registered with the ServletRequest on which the asynchronous 
operation was initiated. 
■ If none of the listeners called AsyncContext.complete() or any of the 
AsyncContext.dispatch methods, perform an error dispatch with a status 
code equal to HttpServletResponse.SC_INTERNAL_SERVER_ERROR. 
■ If no matching error page was found, or the error page did not call 
AsyncContext.complete() or any of the AsyncContext.dispatch 
methods, the container MUST call AsyncContext.complete().

(servlet-3_0-mrel-spec.pdf / pdf page 40, Spec page 18)


In other words, if there are no AsyncListeners which calls AsyncContext.complete() or any of the 
AsyncContext.dispatch, the container must perform an error dispatch with 500 error code.

But tomcat 7 does not send 500 error response. It sends 200 OK.

In org.apache.catalina.core.AsyncContextImpl.timeout(), 

                if (listenerInvoked) {
                    request.getCoyoteRequest().action(
                            ActionCode.ASYNC_IS_TIMINGOUT, result);
                    return !result.get();
                } else {
                    // No listeners, container calls complete
                    complete();
                }

it just calls complete(). So I think it must be spec violation.


I've attached the test war file within a test source.
Test URL is http://localhost:8080/asyncTimeoutTest/AsyncTimeoutTestServlet .
Comment 1 Mark Thomas 2012-11-11 23:36:37 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.33 onwards.

"error dispatch" is not defined anywhere I could find in the servlet spec. I implemented based on what I could deduce from the spec text quoted in this issue.
Comment 2 Eugene Chung (TmaxSoft) 2012-11-12 01:26:01 UTC
Yes, I haven't seen the def. of 'error dispatch', too. In our product, I just used response.sendError(500) that was internally using forward with DispatcherType.ERROR.