I also had hard time understanding the timeout. Spent almost 2 hours this morning on this, experimented a lot, and finally I think I have understood what it means.
Async Timeout will start from the moment when the service method of your Async Servlet has returned to the container.
See following code for async servlet:
In the servlet code above I have set the timeout to 1 sec. and
code for AsyncProcess is :
To complete the AsyncProcess it will take atleast 4 seconds, so timeout occurs.
Now I modified my AsyncServlet code to this:
Here still the timeout is 1 sec and AsyncProcess is started just after the setting of timeout, so here also timeout should occur. But it does NOT. Why? because the service method has not yet returned to the container.
So I concluded from this that:
service() method is the container-initiated dispatch that the specification is talking about:
The timeout applies to this AsyncContext once the container-initiated dispatch during which one of the ServletRequest#startAsync methods was called has returned to the container.
read it like this :
The timeout applies to this AsyncContext once the service() method during which one of the ServletRequest#startAsync methods was called has returned to the container.