We can call dispatch after we dispatched.
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 21 Jul 2009 13:11:04 +0000 (13:11 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 21 Jul 2009 13:11:04 +0000 (13:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@796284 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/AsyncContextImpl.java

index 1c14b8c..daf9442 100644 (file)
@@ -80,7 +80,9 @@ public class AsyncContextImpl implements AsyncContext {
 
     public void dispatch(ServletContext context, String path) {
         // TODO SERVLET3 - async
-        if (this.state.compareAndSet(AsyncState.STARTED, AsyncState.DISPATCHING)) {
+        if (state.compareAndSet(AsyncState.STARTED, AsyncState.DISPATCHING) ||
+            state.compareAndSet(AsyncState.DISPATCHED, AsyncState.DISPATCHING)) {
+
             if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
                 request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
                 request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
@@ -159,7 +161,7 @@ public class AsyncContextImpl implements AsyncContext {
         if (state.compareAndSet(AsyncState.NOT_STARTED, AsyncState.STARTED)) {
             this.context = context;
         } else {
-            throw new IllegalStateException("Already started.");
+            throw new IllegalStateException("Start illegal. Invalid state: "+state.get());
         }
     }