Bug 56736 - IllegalStateException after calling AsyncContext.dispatch
Summary: IllegalStateException after calling AsyncContext.dispatch
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.9
Hardware: All All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-07-17 08:15 UTC by marko asplund
Modified: 2014-08-07 10:34 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description marko asplund 2014-07-17 08:15:47 UTC
Requests timeout occasionally with the following error after calling AsyncContext.dispatch:

10-Jul-2014 01:40:33.145 SEVERE [http-nio-8080-exec-2] org.apache.catalina.connector.CoyoteAdapter.asyncDispatch Exception while processing an asynchronous request
 java.lang.IllegalStateException: Calling [asyncTimeout()] is not valid for a request with Async state [DISPATCHING]
    at org.apache.coyote.AsyncStateMachine.asyncTimeout(AsyncStateMachine.java:267)

Happens also with the Java Blocking Connector (Http11Protocol).

Could not reproduce on Tomcat 7.0.54.

Can be reproduced with the sample project with the following request:

Sample code and more information about the test can be found here:

Verified on:
Ubuntu 14.04 / OpenJDK 1.7.0_55
Mac OS X 10.8.5 / Oracle Java 1.7.0_55
Comment 1 Mark Thomas 2014-08-07 10:34:32 UTC
This has been fixed in 8.0.x for 8.0.11 onwards.

There were actually two problems here. The first was that calls to dispatch() from threads started with AsyncContext.start(Runnable) were not being processed until the AsyncContext timed out. The second was a rare timing issue made much more likely by the previous bug.

The timing issue has also been fixed in 7.0.x for 7.0.56 onwards.