Author: markt Date: Mon Apr 18 20:43:03 2016 New Revision: 1739819 URL: http://svn.apache.org/viewvc?rev=1739819&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=59219 Ensure AsyncListener.onError() is called if an Exception is thrown during async processing.
Modified: tomcat/tc8.5.x/trunk/ (props changed) tomcat/tc8.5.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java tomcat/tc8.5.x/trunk/java/org/apache/coyote/AsyncStateMachine.java tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc8.5.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Apr 18 20:43:03 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 +/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 Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=1739819&r1=1739818&r2=1739819&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Mon Apr 18 20:43:03 2016 @@ -98,9 +98,15 @@ 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 trigger error page handling - it - // will be triggered later if required. + // container thread finishes, do not process any error page here. if (request.isAsync() && !request.isAsyncCompleting()) { + // 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/tc8.5.x/trunk/java/org/apache/coyote/AsyncStateMachine.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1739819&r1=1739818&r2=1739819&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/AsyncStateMachine.java [UTF-8] Mon Apr 18 20:43:03 2016 @@ -52,24 +52,27 @@ 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() | | - * | | | | | | | | - * | \|/ | | complete() \|/ post() | | | + * |-----------------»------| + * | \|/ + * | |----------«-------ERROR-----------------------------------«-------------------------------| + * | | complete() /|\/|\\ | + * | | | | \ | + * | | |-----»-------| | \-----------»----------| | + * | | | | |dispatch() | + * | | | | \|/ | + * | | | | |--|timeout() | | + * | | | post() | | \|/ | post() | + * | | | |---------- | --»DISPATCHED«---------- | --------------COMPLETING«-----| | + * | | | | | /|\ | | | /|\ | | + * | | | | |---»- | ---| | | |--| | | + * | | ^ ^ | | |startAsync() | timeout() | | + * | | | | | \ | | | | + * | | | | | \ | | | | + * | | | | | \ | | | | + * | | | | | \ | | | | + * | \|/ | | | \ \|/ post() | | | * | MUST_COMPLETE-«- | ----«------STARTING--»--------- | -------------| ^ | - * | /|\ /|\ | | | | complete() | | + * | /|\ /|\ | complete() | | | complete() | | * | | | | | | post() | /----------| | * | | | ^ |dispatch() | |-----| | / | * | | | | | | | | | / | @@ -357,8 +360,10 @@ public class AsyncStateMachine { public synchronized void asyncError() { - if (state == AsyncState.DISPATCHED || + if (state == AsyncState.STARTING || + state == AsyncState.DISPATCHED || state == AsyncState.TIMING_OUT || + state == AsyncState.MUST_COMPLETE || state == AsyncState.READ_WRITE_OP) { clearNonBlockingListeners(); state = AsyncState.ERROR; 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=1739819&r1=1739818&r2=1739819&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Mon Apr 18 20:43:03 2016 @@ -75,6 +75,10 @@ (violetagg) </fix> <fix> + <bug>59219</bug>: Ensure <code>AsyncListener.onError()</code> is called + if an <code>Exception</code> is thrown during async processing. (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