-
Bug
-
Resolution: Done
-
Major
-
3.0.10.Final
-
None
I'm try to resume an AsyncResponse with Netty 4 NettyJaxrsServer on a separate thread as seen in [2].
The AsyncResponse succeeds but the resume method fails after returning with an internal exception [3].
It seems related to how ResteasyProviderFactory.getContextDataMap() and ResteasyProviderFactory.clearContextData() interact. After the AsyncResponse commits the context is cleared which cause the "resume" method to fail because it cannot find UriInfo.
I was expecting getContextDataMap to push a context map on the stack, but it gets overwritten instead.
Surprisingly, this only happens JacksonJaxbJsonProvider and ResteasyJackson2Provider have been registered with ResteasyProviderFactory and ResteasyDeployment [1].
[1] ----
ObjectMapper objectMapper = new ObjectMapper();
ResteasyJackson2Provider resteasyJackson2Provider = new ResteasyJackson2Provider();
resteasyJackson2Provider.setMapper(objectMapper);
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
factory.registerProviderInstance(provider);
Jackson2JsonpInterceptor interceptor = new Jackson2JsonpInterceptor();
factory.registerProviderInstance(interceptor);
NettyJaxrsServer server = new NettyJaxrsServer();
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setProviderFactory(factory);
deployment.setApplication(new Application() {
@Override
public Set<Object> getSingletons()
});
server.setDeployment(deployment);
server.start();
[2] -------------
@Path("/test")
public class TestEndpoint {
static LinkedList<AsyncResponse> responses = new LinkedList<AsyncResponse>();
@GET
@Path("resume")
public String resume()
@GET
@Path("async")
public void async(@Suspended final AsyncResponse test)
}
[3] -----------
SEVERE: Failed executing GET /test/resume
org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.UriInfo
at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)
at com.sun.proxy.$Proxy21.getQueryParameters(Unknown Source)
at org.jboss.resteasy.plugins.providers.jackson.Jackson2JsonpInterceptor.aroundWriteTo(Jackson2JsonpInterceptor.java:103)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)
at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:99)
at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:427)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
at org.jboss.resteasy.plugins.server.netty.RequestHandler.channelRead0(RequestHandler.java:53)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:32)
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:299)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:745)
Jan 15, 2015 10:55:32 PM org.jboss.resteasy.plugins.server.netty.RequestHandler
SEVERE: Unexpected
org.jboss.resteasy.spi.UnhandledException: org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.UriInfo
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:157)
at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:432)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
at org.jboss.resteasy.plugins.server.netty.RequestHandler.channelRead0(RequestHandler.java:53)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:32)
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:299)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.UriInfo
at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)
at com.sun.proxy.$Proxy21.getQueryParameters(Unknown Source)
at org.jboss.resteasy.plugins.providers.jackson.Jackson2JsonpInterceptor.aroundWriteTo(Jackson2JsonpInterceptor.java:103)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)
at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:99)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:153)
... 14 more