FAQ
Author: markt
Date: Wed Oct 29 21:01:06 2014
New Revision: 1635301

URL: http://svn.apache.org/r1635301
Log:
With the changes to the behaviour AsyncContext.isStarted() this method can no longer be used to determine if complete needs to be called to add a new method that can provide this information.

Modified:
     tomcat/trunk/java/org/apache/catalina/connector/Request.java
     tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
     tomcat/trunk/java/org/apache/coyote/ActionCode.java
     tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
     tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=1635301&r1=1635300&r2=1635301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Wed Oct 29 21:01:06 2014
@@ -1634,6 +1634,16 @@ public class Request
          return result.get();
      }

+ public boolean canAsyncComplete() {
+ if (asyncContext == null) {
+ return false;
+ }
+
+ AtomicBoolean result = new AtomicBoolean(false);
+ coyoteRequest.action(ActionCode.ASYNC_CAN_COMPLETE, result);
+ return result.get();
+ }
+
      public boolean isAsync() {
          if (asyncContext == null) {
              return false;

Modified: tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=1635301&r1=1635300&r2=1635301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Wed Oct 29 21:01:06 2014
@@ -123,7 +123,7 @@ public class ErrorReportValve extends Va
              ExceptionUtils.handleThrowable(tt);
          }

- if (request.isAsyncStarted()) {
+ if (request.canAsyncComplete()) {
              request.getAsyncContext().complete();
          }
      }

Modified: tomcat/trunk/java/org/apache/coyote/ActionCode.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ActionCode.java?rev=1635301&r1=1635300&r2=1635301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ActionCode.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ActionCode.java Wed Oct 29 21:01:06 2014
@@ -158,6 +158,12 @@ public enum ActionCode {
      ASYNC_RUN,

      /**
+ * Call back to see if it is currently possible to call
+ * {@link javax.servlet.AsyncContext#complete()} without error.
+ */
+ ASYNC_CAN_COMPLETE,
+
+ /**
       * Callback for an async call to
       * {@link javax.servlet.AsyncContext#complete()}
       */

Modified: tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1635301&r1=1635300&r2=1635301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] (original)
+++ tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] Wed Oct 29 21:01:06 2014
@@ -19,7 +19,6 @@ package org.apache.coyote;
  import java.security.AccessController;
  import java.security.PrivilegedAction;

-import org.apache.catalina.Globals;
  import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
  import org.apache.tomcat.util.res.StringManager;
  import org.apache.tomcat.util.security.PrivilegedGetTccl;
@@ -107,38 +106,44 @@ public class AsyncStateMachine {
          StringManager.getManager(Constants.Package);

      private static enum AsyncState {
- DISPATCHED(false, false, false),
- STARTING(true, true, false),
- STARTED(true, true, false),
- MUST_COMPLETE(true, Globals.STRICT_SERVLET_COMPLIANCE, false),
- COMPLETING(true, false, false),
- TIMING_OUT(true, false, false),
- MUST_DISPATCH(true, true, true),
- DISPATCHING(true, false, true),
- READ_WRITE_OP(true,true,false),
- ERROR(true,false,false);
-
- private boolean isAsync;
- private boolean isStarted;
- private boolean isDispatching;
+ DISPATCHED(false, false, false, false),
+ STARTING(true, true, true, false),
+ STARTED(true, true, true, false),
+ MUST_COMPLETE(true, true, false, false),
+ COMPLETING(true, false, false, false),
+ TIMING_OUT(true, false, false, false),
+ MUST_DISPATCH(true, true, false, true),
+ DISPATCHING(true, false, false, true),
+ READ_WRITE_OP(true, true, true, false),
+ ERROR(true, false, false, false);
+
+ private final boolean isAsync;
+ private final boolean isStarted;
+ private final boolean canComplete;
+ private final boolean isDispatching;

- private AsyncState(boolean isAsync, boolean isStarted,
+ private AsyncState(boolean isAsync, boolean isStarted, boolean canComplete,
                  boolean isDispatching) {
              this.isAsync = isAsync;
              this.isStarted = isStarted;
+ this.canComplete = canComplete;
              this.isDispatching = isDispatching;
          }

          public boolean isAsync() {
- return this.isAsync;
+ return isAsync;
          }

          public boolean isStarted() {
- return this.isStarted;
+ return isStarted;
          }

          public boolean isDispatching() {
- return this.isDispatching;
+ return isDispatching;
+ }
+
+ public boolean canComplete() {
+ return canComplete;
          }
      }

@@ -174,6 +179,10 @@ public class AsyncStateMachine {
          return state == AsyncState.ERROR;
      }

+ public boolean canComplete() {
+ return state.canComplete();
+ }
+
      public synchronized void asyncStart(AsyncContextCallback asyncCtxt) {
          if (state == AsyncState.DISPATCHED) {
              state = AsyncState.STARTING;

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java?rev=1635301&r1=1635300&r2=1635301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java Wed Oct 29 21:01:06 2014
@@ -522,6 +522,10 @@ public abstract class AbstractAjpProcess
              getSocketWrapper().access();
              break;
          }
+ case ASYNC_CAN_COMPLETE: {
+ ((AtomicBoolean) param).set(asyncStateMachine.canComplete());
+ break;
+ }
          case ASYNC_COMPLETE: {
              socketWrapper.clearDispatches();
              if (asyncStateMachine.asyncComplete()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupdev @
categoriestomcat
postedOct 29, '14 at 9:02p
activeOct 29, '14 at 9:02p
posts1
users1
websitetomcat.apache.org
irc#tomcat

1 user in discussion

Markt: 1 post

People

Translate

site design / logo © 2017 Grokbase