Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-917

Resuming AyncResponse cause IllegalStateException "Unknown media type"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • 3.0.3.Final
    • 3.0.2.Final
    • jaxrs
    • None

      I have made some observations using AsyncResponse with a MessageBodyWriter that seems a little strange.

      1) Calling AsyncResponse.resume() with a user-defined object (intended for MessageBodyWriter) on same thread as the running request cause an exception almost immediately after returning (see below).

      2) Calling AsyncResponse.resume() by wrapping the object, Response.ok().entity(object).build(), works and MessageBodyWriter writes the response.

      3) Calling AsyncResponse.resume() on a separate thread (with a user-defined object), exactly like the example in AsyncResponse javadoc, the response is written correctly by the MessageBodyWriter. However, if I simulate a pause AFTER putting the response on the queue and let postMessage steal the response BEFORE returning from readMessage method, I get the same exception as 1).

      Comments:

      1) Seems like this should just work? Or must every resume() object be wrapped in a Response object, like comment 2?

      3) Imagine posting AsyncResponse to an executor that finish before returning from the originating method call. That would result in the same error as 1). Seems like a race-condition. Maybe unlikely, but still.

      org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: Unknown media type for response entity
      at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) ~[javax.servlet-3.0.0.v201112011016.jar:na]
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698) ~[jetty-servlet-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:505) [jetty-servlet-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:211) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1094) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432) [jetty-servlet-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1028) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.Server.handle(Server.java:445) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:267) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:224) [jetty-server-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358) [jetty-io-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601) [jetty-util-9.0.4.v20130625.jar:9.0.4.v20130625]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532) [jetty-util-9.0.4.v20130625.jar:9.0.4.v20130625]
      at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
      Caused by: java.lang.IllegalStateException: Unknown media type for response entity
      at org.jboss.resteasy.core.AbstractAsynchronousResponse.internalResume(AbstractAsynchronousResponse.java:165) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at org.jboss.resteasy.core.SynchronousExecutionContext$SynchronousAsynchronousResponse.resume(SynchronousExecutionContext.java:87) ~[resteasy-jaxrs-3.0.1.Final.jar:na]
      at x.x.x.(X.java:39) ~[classes/:na]

              patriot1burke@gmail.com Bill Burke (Inactive)
              krisskross_jira Kristoffer Sjögren (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: