tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Violeta Georgieva <>
Subject AsyncContext.dispatch(path) invoked more than once
Date Tue, 28 May 2013 18:51:28 GMT

In the AsyncContext.dispatch(path) javadoc we have:

"There can be at most one asynchronous dispatch operation per asynchronous
cycle, which is started by a call to one of the
Any attempt to perform an additional asynchronous dispatch
operation within the same asynchronous cycle will result in an
IllegalStateException. If startAsync is subsequently called on the
dispatched request, then any of the dispatch or
may be called."

If we have the following scenario:

AsyncContext asyncContext = request.startAsync(request, response);
asyncContext .dispatch("/resourceA");
asyncContext .dispatch("/resourceB");

I would assume that the second dispatch will throw ISE and a dispatching to
the "resourceA" will happen.

The current implementation (tomcat7/8) throws ISE but the dispatching is to
the "resourceB".

I prepared a change (below) that moves the check for ISE a little bit
earlier. o.a.catalina.core.AsyncContextImpl.dispatch field is not
overridden with information from the second dispatch() invocation, thus a
dispatching to "resourceA" will happen.

What do you think? Are my assumptions correct?


Index: C:/tc8.0.x/java/org/apache/catalina/core/
--- C:/tc8.0.x/java/org/apache/catalina/core/ (revision
+++ C:/tc8.0.x/java/org/apache/catalina/core/ (working
@@ -216,8 +216,8 @@

+        this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH,
         this.dispatch = run;
-        this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message