You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/04/18 22:35:27 UTC

svn commit: r1739817 - in /tomcat/trunk/java/org/apache: catalina/valves/ErrorReportValve.java coyote/AsyncStateMachine.java

Author: markt
Date: Mon Apr 18 20:35:27 2016
New Revision: 1739817

URL: http://svn.apache.org/viewvc?rev=1739817&view=rev
Log:
Remainder of fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=59219
If an exception is throw during a dispatch(), trigger the Async error handling process

Modified:
    tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
    tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java

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=1739817&r1=1739816&r2=1739817&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Mon Apr 18 20:35:27 2016
@@ -98,11 +98,13 @@ public class ErrorReportValve extends Va
         Throwable throwable = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
 
         // If an async request is in progress and is not going to end once this
-        // container thread finishes, do not process the error page here but
-        // trigger an error dispatch so the additional async processing such as
-        // firing onError() occurs.
+        // container thread finishes, do not process any error page here.
         if (request.isAsync() && !request.isAsyncCompleting()) {
-            if (throwable != null) {
+            // If an async dispatch is in progress the error handling in the
+            // CoyoteAdapter will trigger the necessary processing. It is only
+            // necessary to trigger it here if async is starting (i.e. this is
+            // the post-processing of the service() method)
+            if (throwable != null && request.isAsyncDispatching()) {
                 request.getAsyncContextInternal().setErrorState(throwable, true);
             }
             return;

Modified: tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1739817&r1=1739816&r2=1739817&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] (original)
+++ tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] Mon Apr 18 20:35:27 2016
@@ -52,25 +52,25 @@ import org.apache.tomcat.util.security.P
  * DISPATCHING   - The dispatch is being processed.
  * ERROR         - Something went wrong.
  *
- * |-----------------»--------|
- * |                         \|/
- * |   |----------«---------ERROR---------------------------------«-------------------------------|
- * |   |      complete()    /|\  \                                                                |
- * |   |                     |    \---------------------|                                         |
- * |   |                     |                          |dispatch()                               |
- * |   |                     |                         \|/                                        |
- * |   |                     |                          |                                         |
- * |   |                     |          |--|timeout()   |                                         |
- * |   |          post()     |          | \|/           |     post()                              |
- * |   |         |---------- | --»DISPATCHED«---------- | --------------COMPLETING«-----|         |
- * |   |         |           |   /|\  |                 |                 | /|\         |         |
- * |   |         |    |---»- | ---|   |                 |                 |--|          |         |
- * |   |         ^    |      |        |startAsync()     |               timeout()       |         |
- * |   |         |    |       \       |                 |                               |         |
- * |   |         |    |        \      |                 |                               |         |
- * |   |         |    |         \     |                 |                               |         |
- * |   |         |    |          \    |                 |                               |         |
- * |  \|/        |    |           \  \|/     post()     |                               |         |
+ * |-----------------»------|
+ * |                       \|/
+ * |   |----------«-------ERROR-----------------------------------«-------------------------------|
+ * |   |      complete() /|\/|\\                                                                  |
+ * |   |                  |  |  \                                                                 |
+ * |   |    |-----»-------|  |   \-----------»----------|                                         |
+ * |   |    |                |                          |dispatch()                               |
+ * |   |    |                |                         \|/                                        |
+ * |   |    |                |          |--|timeout()   |                                         |
+ * |   |    |     post()     |          | \|/           |     post()                              |
+ * |   |    |    |---------- | --»DISPATCHED«---------- | --------------COMPLETING«-----|         |
+ * |   |    |    |           |   /|\  |                 |                 | /|\         |         |
+ * |   |    |    |    |---»- | ---|   |                 |                 |--|          |         |
+ * |   |    ^    ^    |      |        |startAsync()     |               timeout()       |         |
+ * |   |    |    |    |       \       |                 |                               |         |
+ * |   |    |    |    |        \      |                 |                               |         |
+ * |   |    |    |    |         \     |                 |                               |         |
+ * |   |    |    |    |          \    |                 |                               |         |
+ * |  \|/   |    |    |           \  \|/     post()     |                               |         |
  * | MUST_COMPLETE-«- | ----«------STARTING--»--------- | -------------|                ^         |
  * |  /|\    /|\      |  complete()   |                 |              |     complete() |         |
  * |   |      |       |               |                 |    post()    |     /----------|         |
@@ -363,6 +363,7 @@ public class AsyncStateMachine {
         if (state == AsyncState.STARTING ||
                 state == AsyncState.DISPATCHED ||
                 state == AsyncState.TIMING_OUT ||
+                state == AsyncState.MUST_COMPLETE ||
                 state == AsyncState.READ_WRITE_OP) {
             clearNonBlockingListeners();
             state = AsyncState.ERROR;



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