Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5659

IllegalStateException on Async call

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.7.10
    • None
    • Transports
    • Unknown

    Description

      I've come acrossed an odd exception when attempting to use an Async JAX-WS Provider:

      java.lang.IllegalStateException: s=DISPATCHED i=false a=null
      	at org.eclipse.jetty.server.HttpChannelState.complete(HttpChannelState.java:430)
      	at org.eclipse.jetty.server.AsyncContextState.complete(AsyncContextState.java:92)
      	at org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation.reset(Servlet3ContinuationProvider.java:131)
      	at org.apache.cxf.transport.http.Servlet3ContinuationProvider.complete(Servlet3ContinuationProvider.java:55)
      	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:242)
      	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:248)
      	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:222)
      	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:153)
      	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:167)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:206)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:717)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:544)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1112)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1046)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      	at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      	at org.eclipse.jetty.server.Server.handleAsync(Server.java:516)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:288)
      	at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:237)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
      	at java.lang.Thread.run(Thread.java:722)

      From what I've been able to determine, it appears it is attempting to call AsyncContext.complete() after AsyncContext.dispatch() has been called from Servlet3Continuation.redispatch()/resume().

      I changed the Servlet3.Continuation.reset() method to this to 'fix' it:

              public void reset() {
                  if (!isResumed) {
                      context.complete();
                  }
                  obj = null;
              }

      But I'm not sure if that's correct.

      I also changed the Servlet3Continuation.startAsyncAgain() method, as I spotted it adding a duplicate listener:

              void startAsyncAgain() {
                  AsyncContext old = context;
                  try {
                      context = req.startAsync();
                      context.addListener(this);
                  } catch (IllegalStateException ex) { 
                      context = old;
                  }
              }

      Attachments

        Activity

          People

            Unassigned Unassigned
            elfarto Stephen Dawkins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: