Author: markt
Date: Tue Apr 19 18:44:38 2016
New Revision: 1739978

URL: http://svn.apache.org/viewvc?rev=1739978&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=59220
Ensure that AsyncListener.onComplete() is called if the async request times out 
and the response is already committed.

Modified:
    tomcat/tc8.5.x/trunk/   (props changed)
    tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/tc8.5.x/trunk/java/org/apache/coyote/ActionCode.java
    tomcat/tc8.5.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/tc8.5.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/tc8.5.x/trunk/java/org/apache/coyote/http2/StreamProcessor.java
    tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc8.5.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 19 18:44:38 2016
@@ -1 +1 @@
-/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818
+/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818,1739975

Modified: 
tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 
Tue Apr 19 18:44:38 2016
@@ -253,6 +253,12 @@ public class CoyoteAdapter implements Ad
             AtomicBoolean error = new AtomicBoolean(false);
             res.action(ActionCode.IS_ERROR, error);
             if (error.get()) {
+                if (request.isAsyncCompleting()) {
+                    // Connection will be forcibly closed which will prevent
+                    // completion happening at the usual point. Need to trigger
+                    // call to onComplete() here.
+                    res.action(ActionCode.ASYNC_POST_PROCESS,  null);
+                }
                 success = false;
             }
         } catch (IOException e) {

Modified: tomcat/tc8.5.x/trunk/java/org/apache/coyote/ActionCode.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/ActionCode.java?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/coyote/ActionCode.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/ActionCode.java Tue Apr 19 
18:44:38 2016
@@ -189,6 +189,12 @@ public enum ActionCode {
     ASYNC_IS_ERROR,
 
     /**
+     * Callback to trigger post processing. Typically only used during error
+     * handling to trigger essential processing that otherwise would be 
skipped.
+     */
+    ASYNC_POST_PROCESS,
+
+    /**
      * Callback to trigger the HTTP upgrade process.
      */
     UPGRADE,

Modified: tomcat/tc8.5.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Tue Apr 
19 18:44:38 2016
@@ -596,6 +596,10 @@ public class AjpProcessor extends Abstra
             result.set(asyncStateMachine.asyncTimeout());
             break;
         }
+        case ASYNC_POST_PROCESS: {
+            asyncStateMachine.asyncPostProcess();
+            break;
+        }
 
         // Servlet 3.1 non-blocking I/O
         case REQUEST_BODY_FULLY_READ: {

Modified: 
tomcat/tc8.5.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/coyote/http11/Http11Processor.java 
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue 
Apr 19 18:44:38 2016
@@ -901,6 +901,10 @@ public class Http11Processor extends Abs
             result.set(asyncStateMachine.asyncTimeout());
             break;
         }
+        case ASYNC_POST_PROCESS: {
+            asyncStateMachine.asyncPostProcess();
+            break;
+        }
 
         // Servlet 3.1 non-blocking I/O
         case REQUEST_BODY_FULLY_READ: {

Modified: tomcat/tc8.5.x/trunk/java/org/apache/coyote/http2/StreamProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/http2/StreamProcessor.java?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/coyote/http2/StreamProcessor.java 
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/http2/StreamProcessor.java Tue 
Apr 19 18:44:38 2016
@@ -316,6 +316,10 @@ public class StreamProcessor extends Abs
             result.set(asyncStateMachine.asyncTimeout());
             break;
         }
+        case ASYNC_POST_PROCESS: {
+            asyncStateMachine.asyncPostProcess();
+            break;
+        }
 
         // Servlet 3.1 non-blocking I/O
         case REQUEST_BODY_FULLY_READ: {

Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1739978&r1=1739977&r2=1739978&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Tue Apr 19 18:44:38 2016
@@ -79,6 +79,11 @@
         if an <code>Exception</code> is thrown during async processing. (markt)
       </fix>
       <fix>
+        <bug>59220</bug>: Ensure that <code>AsyncListener.onComplete()</code> 
is
+        called if the async request times out and the response is already
+        committed. (markt)
+      </fix>
+      <fix>
         <bug>59255</bug>: Fix possible NPE in mapper. (kkolinko/remm)
       </fix>
       <fix>



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

Reply via email to