Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-31

UT010025: Async request already dispatched

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0.Alpha8
    • 1.0.0.Alpha7
    • Servlet
    • 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.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              rhn-engineering-jharting Jozef Hartinger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: