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

Reply via email to