Mantis - Resin
Viewing Issue Advanced Details
5420 major always 04-15-13 18:09 05-29-13 10:35
bhauer1  
ferg  
normal  
closed 4.0.35  
fixed  
none    
none 4.0.37  
0005420: AsyncContext completed by original synchronous worker thread?
It is possible I am doing something wrong, but in Resin 4.0.35, AsyncContexts are being completed immediately when the synchronous worker thread handling a request returns to Resin (after Servlet.service() is done).

In other words, it is impossible to work with an AsyncContext once the Servlet's service() method returns, which seems to work against the purpose of AsyncContext.
I am attaching a simple example Servlet that responds immediately and synchronously to /test and responds asynchronously after a 2 second delay to /test?type=async.

The asynchronous version calls request.startAsync, attaches an AsyncListener, and submits a Runnable to a ScheduledExecutorService to run after 2 seconds.

The AsyncListener will show a call to onComplete() immediately (at the conclusion of the service() method). By the time the ScheduledExecutorService runs the Runnable, the AsyncContext has been closed and the Runnable freezes up.

If you print a Throwable in the listener's onComplete method, the following stack trace is visible:

at com.caucho.server.http.AsyncListenerNode.onComplete(AsyncListenerNode.java:83)
at com.caucho.server.http.AsyncContextImpl.onComplete(AsyncContextImpl.java:379)
at com.caucho.server.http.HttpServletRequestImpl.finishRequest(HttpServletRequestImpl.java:1696)
at com.caucho.server.http.AbstractHttpRequest.finishRequest(AbstractHttpRequest.java:1848)
at com.caucho.server.hmux.HmuxRequest.handleRequestImpl(HmuxRequest.java:385)
...

Shouldn't the request remain alive until the AsyncContext.complete() method is called?
related to 0005268closed ferg NPE using Asynch Servlet over Hmux 
 AsyncTest.java [^] (2,733 bytes) 04-15-13 18:09

Notes
(0006267)
ferg   
05-29-13 10:35   
server/1ld7

Note: this issue is specific to Hmux, i.e. Resin behind a load balancer.