[jax-rs-spec users] [jsr339-experts] Re: Async.setTimeout conflicts with servlet's setTimeout

From: Sergey Beryozkin <>
Date: Mon, 12 Aug 2013 15:37:01 +0300

On 12/08/13 15:33, Bill Burke wrote:
> On 8/12/2013 3:20 AM, Sergey Beryozkin wrote:
>> On 06/08/13 19:54, Bill Burke wrote:
>>> JAX-RS AsyncResponse.setTimeout() javadoc implies that this method can
>>> be called in any thread....
>>> Unfortunately, if you build AsyncResponse on top of the Servlet 3 async
>>> APIs, AsyncContext.setTimeout() can only be executed in the same thread
>>> as the initial HTTP request.
>>> "IllegalStateException - if this method is called after the
>>> container-initiated dispatch, during which one of the
>>> ServletRequest#startAsync methods was called, has returned to the
>>> container "
>> I read it like this: "if the container-initiated dispatch has returned
>> to the container (i.e, has completed) and setTimeout is called
>> afterwards then throw ISE"
> For Jetty at least, it ignores the setTimeout call in a separate thread.
> Our servlet guys think that a exception should be thrown. Haven't
> tried Tomcat.
I've tried with Tomcat before, worked for me, and we have Jetty-based
tests running with setTimeout called too, may be you have an older Jetty
version ? I can post you a link offline to our test source code

Cheers, Sergey