Bug 49528 - HttpServletRequest.isAsyncStarted() returns false when a Runnable is started
Summary: HttpServletRequest.isAsyncStarted() returns false when a Runnable is started
Status: CLOSED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 7.0.0
Hardware: PC Linux
: P2 blocker (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 06:32 UTC by Pieter Libin
Modified: 2010-07-07 09:35 UTC (History)
1 user (show)



Attachments
Servlet 3.0 isAsyncStarted testcase (1.74 KB, text/x-java)
2010-06-30 06:32 UTC, Pieter Libin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pieter Libin 2010-06-30 06:32:11 UTC
Created attachment 25667 [details]
Servlet 3.0 isAsyncStarted testcase

In the attached example, an async request is created, but within a Runnable started using AsyncContext.start() the isAsyncStarted() returns false. 

This conflicts with the servlet 3.0 specification. Quoting chapter "2.3.3.3 Asynchronous processing" : "
  public boolean isAsyncStarted() - Returns true if async processing
  has started on this request, and false otherwise. If this request has been
  dispatched using one of the AsyncContext.dispatch methods since it was
  put in asynchronous mode, or a call to AsynContext.complete is made, this
  method returns false.
"

This output is generated by Tomcat 7.0.0:

Start async()
Dispatching start()
request.isAsyncStarted()1true
Returning from doGet()
request.isAsyncStarted()2false
Before sleep()
After sleep()
request.isAsyncStarted()3false
Returning from run()
request.isAsyncStarted()4false

The following output is what we would expect and what Jetty v8.0 generates:

Start async()
Dispatching start()
request.isAsyncStarted()1true
Returning from doGet()
request.isAsyncStarted()2true
Before sleep()
After sleep()
request.isAsyncStarted()3true
Returning from run()
request.isAsyncStarted()4false
Comment 1 Mark Thomas 2010-07-02 14:32:27 UTC
Please could you confirm that the test case is provided under the terms of section 5 of the Apache License, v2 and that you have the right to provide this code under those terms. The header in the test case seems to suggest otherwise.
Comment 2 Peter Rossbach 2010-07-03 18:51:16 UTC
Check Revision 960283 and review my  test case TestAsyncContextImpl.

Fix is proposed at tomcat 7.0.1

Many thanks to report this bug.
Peter
Comment 3 Mark Thomas 2010-07-04 11:22:01 UTC
The fix breaks the Servlet TCK and therefore will have to be reverted.
Comment 4 Mark Thomas 2010-07-04 16:39:54 UTC
I have reverted the original fix and applied a new fix that fixes the issue described here and still passes the Servlet TCK.
Comment 5 Pieter Libin 2010-07-05 03:55:31 UTC
(In reply to comment #1)
> Please could you confirm that the test case is provided under the terms of
> section 5 of the Apache License, v2 and that you have the right to provide this
> code under those terms. The header in the test case seems to suggest otherwise.

Yes, that's fine.
Comment 6 Pieter Libin 2010-07-05 03:56:31 UTC
(In reply to comment #4)
> I have reverted the original fix and applied a new fix that fixes the issue
> described here and still passes the Servlet TCK.

Thanks for the quick fix! I'll give it a try.
Comment 7 Pieter Libin 2010-07-05 09:06:05 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > I have reverted the original fix and applied a new fix that fixes the issue
> > described here and still passes the Servlet TCK.
> 
> Thanks for the quick fix! I'll give it a try.

Dear All,

when I run the test case on the latest version of the tomcat trunk,
I get the following output, which looks like the Runnable we try to start is never executed:

Start async()
Dispatching start()
request.isAsyncStarted()1true
Returning from doGet()
Comment 8 Mark Thomas 2010-07-05 12:48:17 UTC
Yep. The test only looked at the correctness of the return values present, it didn't check all the expected return values were present. I have fixed the test case and am looking at the additional changes required now. Should be quite quick.
Comment 9 Mark Thomas 2010-07-05 16:51:52 UTC
Sorry about that. Fixed in trunk. Will be in 7.0.1 onwards.
Comment 10 Pieter Libin 2010-07-05 17:15:08 UTC
(In reply to comment #9)
> Sorry about that. Fixed in trunk. Will be in 7.0.1 onwards.

Thanks a lot for the quick response! 
I'll retest from the trunk tomorrow morning.
Comment 11 Pieter Libin 2010-07-07 09:25:06 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > Sorry about that. Fixed in trunk. Will be in 7.0.1 onwards.
> 
> Thanks a lot for the quick response! 
> I'll retest from the trunk tomorrow morning.

this problem appears to be fixed, thanks a lot!

However, I ran into another problem,
which I reported as new bug (49567).