Hi,

I am trying to build a Streaming solution on top of Tomcat and using Async
servlets. What I am doing is I start an asynchronous process using
`startAsync()` and then attach a ReadListener which streams the data
forward `onDataAvailable`, the consumer consumes this on another thread.
Now the problem I am running into is if the there is a
SocketTimeoutException during the read, onError of ReadListener is
triggered and I pass that forward, however I don't call
AsyncContext.complete, because I want the async thread processing the data
to be first able to deal with the exception and then I close it on the
async thread when its done.

However what I am observing is irrespective of if my not closing the
context, it's closed by default by Tomcat and the request/response objects
are recycled. Due to this during the error handling when I am trying to
read some headers I get a IllegalStateException. I don't want to do the
clean up on the IO thread since it can be heavy and I don't want to
overwhelm the IO threads.

Is there a way around this, to keep the async context open even on an error
and not close it till complete is invoked?

Thanks,
Adwait.

Reply via email to