Bug 53843

Summary: isAsyncStarted may return false in thread that started async processing
Product: Tomcat 7 Reporter: Rossen Stoyanchev <rstoyanchev>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 7.0.30   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Rossen Stoyanchev 2012-09-08 00:42:57 UTC
After async processing starts in some container thread A, subsequent calls to request.isAsyncStarted() return true as expected.

However as soon as an application thread B calls asyncContext.dispatch(), isAsyncStarted() begins to return false even if the actual dispatch has not yet occurred. For this case the spec says: "the dispatch operation will be delayed until after the container-initiated dispatch has returned to the container."

For the brief period after dispatch() is called but before the actual dispatch begins (and DispatcherType becomes ASYNC), isAsyncStarted should return true. Without that, the return value of isAsyncStarted() may suddenly change while thread A is still exiting causing it to not recognize that async processing started and that it needs to exit as quickly as possible.
Comment 1 Mark Thomas 2012-09-08 15:13:49 UTC
Thanks for the report. The same holds for complete() as well as dispatch(). This has been fixed in trunk and 7.0.x and will be included in 7.0.31 onwards.
Comment 2 Mark Thomas 2012-09-20 09:57:23 UTC
Actually, complete() is different (the TCK fails if we treat it the same way). As soon as complete() is called , isAsyncStarted() must return false.