tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rossen Stoyanchev <>
Subject IOException from the response during an async request
Date Sun, 05 May 2013 12:18:11 GMT

When a request has been put into async mode (via request.startAsync), the response may remain
open long after the initial container thread has exited. Meanwhile a non-container thread
is allowed to write to the response but if an IOException occurs, there is obviously no way
to report it to the client since the error implies we're unable to write to the response any

>From what I can see to complete the async request in this (or any async scenario) one
has to call asyncContext.dispatch(), wait for the dispatch, and then call asyncContext.complete()
in the dispatched thread, or let the dispatched thread complete. And this is true even if
the IOException occurred in the brief period after startAsync but before the initial container
thread has exited.

This is based on the Javadoc of asyncContext.complete() by the way:

* <p>It is legal to call this method any time after a call to
* {@link ServletRequest#startAsync()} or
* {@link ServletRequest#startAsync(ServletRequest, ServletResponse)},
* and before a call to one of the <tt>dispatch</tt> methods
* of this class. 

It seems rather convoluted for dealing with exceptions from the response especially in cases
where the client has gone away, so I just wanted to confirm it's the correct way and the only


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message