You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Juriy Bura <ju...@gmail.com> on 2010/11/20 16:09:11 UTC
Call to dispatch in onTimeout
Hello guys,
Could you please give some comments if the code below is legal from the
Servlet 3.0 spec point of view?
AsyncContext context = request.startAsync();
context.setTimeout(3000);
context.addListener(new AsyncListener() {
public void onComplete(AsyncEvent asyncEvent) throws IOException
{}
public void onTimeout(AsyncEvent asyncEvent) throws IOException
{
System.out.println("HITTING TIMEOUT");
asyncEvent.getAsyncContext().dispatch();
}
public void onError(AsyncEvent asyncEvent) throws IOException {}
public void onStartAsync(AsyncEvent asyncEvent) throws
IOException {}
});
I'm calling the AsyncContext.dispatch() method inside the onTimeout callback
of the listener. On the latest build (7.0.4) it throws the exception:
java.lang.IllegalStateException: Calling [dispatchAsync()] is not valid for
a request with Async state [TIMING_OUT]
// Juriy