-
Bug
-
Resolution: Done
-
Major
-
1.0.0.Alpha7
-
None
Reproducible in the following scenario:
1) A servlet calls startAsync, registers an AsyncListener and spawns a thread
2) The spawned thread dispatches to FaultyServlet
3) FaultyServlet throws an exception
4) AsyncListener.onError() is invoked
5) Within AsyncListener.onError() the AsyncListener writes a response and calls AsyncContext.complete() to mark the error as handled
The following exception appears in the log
java.lang.IllegalStateException: UT010025: Async request already dispatched at io.undertow.servlet.spec.AsyncContextImpl.doDispatch(AsyncContextImpl.java:332) at io.undertow.servlet.spec.AsyncContextImpl.completeInternal(AsyncContextImpl.java:235) at io.undertow.servlet.spec.AsyncContextImpl.complete(AsyncContextImpl.java:219) at io.undertow.servlet.test.listener.request.async.onError.SimpleAsyncListener.onError(SimpleAsyncListener.java:60) at io.undertow.servlet.spec.HttpServletRequestImpl.onAsyncError(HttpServletRequestImpl.java:964) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:129) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:107) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:93) at io.undertow.servlet.spec.AsyncContextImpl$2$1.handleRequest(AsyncContextImpl.java:149) at io.undertow.server.HttpHandlers.executeRootHandler(HttpHandlers.java:53) at io.undertow.servlet.spec.AsyncContextImpl$2.run(AsyncContextImpl.java:146) at io.undertow.servlet.spec.AsyncContextImpl$5.run(AsyncContextImpl.java:340) at io.undertow.servlet.spec.AsyncContextImpl$TaskDispatchRunnable.run(AsyncContextImpl.java:406) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)
This can be reproduced by io.undertow.servlet.test.listener.request.async.onError.AsyncListenerOnErrorTest.testAsyncListenerOnErrorInvoked1()
Note that the test passes but the exception appears in the log.