cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-6929) Request hangs when using JAX-RS AsyncResponse and Exception mapper
Date Fri, 03 Jun 2016 15:07:59 GMT

    [ https://issues.apache.org/jira/browse/CXF-6929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15314255#comment-15314255
] 

Sergey Beryozkin edited comment on CXF-6929 at 6/3/16 3:07 PM:
---------------------------------------------------------------

I've added a couple of tests, all seems to work OK:

http://git-wip-us.apache.org/repos/asf/cxf/commit/c0ad4d31.

I wonder, should you enable an asyncSupported property somehow ?



was (Author: sergey_beryozkin):
I've added a couple of tests, all seem to work OK:

http://git-wip-us.apache.org/repos/asf/cxf/commit/c0ad4d31.

I wonder, should you enable an asyncSupported property somehow ?


> Request hangs when using JAX-RS AsyncResponse and Exception mapper
> ------------------------------------------------------------------
>
>                 Key: CXF-6929
>                 URL: https://issues.apache.org/jira/browse/CXF-6929
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.1, 3.1.6
>            Reporter: Florian Diebold
>
> I have a JAX-RS resource which takes an AsyncResponse, but immediately throws an exception
before returning from the function. If the exception is then mapped by an ExceptionMapper,
the response seems to be never sent, and the request hangs (stays suspended forever). Am I
doing something wrong?
> Example code:
> {code}
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.container.AsyncResponse;
> import javax.ws.rs.container.Suspended;
> import javax.ws.rs.core.Response;
> import javax.ws.rs.ext.ExceptionMapper;
> import org.apache.commons.lang.NotImplementedException;
> import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
> import org.eclipse.jetty.server.Connector;
> import org.eclipse.jetty.server.Server;
> import org.eclipse.jetty.server.ServerConnector;
> import org.eclipse.jetty.servlet.ServletContextHandler;
> import org.eclipse.jetty.servlet.ServletHolder;
> public class ServerDemo2 {
>     public static void main( final String[] args ) throws Exception {
>         final Server server = new Server();
>         final ServerConnector connector = new ServerConnector( server );
>         connector.setHost( "localhost" );
>         connector.setPort( 8888 );
>         server.setConnectors( new Connector[] { connector } );
>         final ServletContextHandler handler = new ServletContextHandler();
>         final ServletHolder holder = new ServletHolder( CXFNonSpringJaxrsServlet.class
);
>         holder.setInitParameter( "jaxrs.serviceClasses", Resource.class.getName() );
>         holder.setInitParameter( "jaxrs.providers", Mapper.class.getName() );
>         handler.addServlet( holder, "/*" );
>         server.setHandler( handler );
>         server.start();
>         System.in.read();
>         server.stop();
>     }
>     public static class Mapper implements ExceptionMapper<NotImplementedException>
{
>         @Override
>         public Response toResponse( final NotImplementedException exception ) {
>             exception.printStackTrace();
>             return Response.ok().build();
>         }
>     }
>     @Path( "/" )
>     public static class Resource {
>         @GET
>         @Path( "/foo" )
>         @Produces( "text/plain" )
>         public void foo( @Suspended final AsyncResponse response ) {
>             throw new NotImplementedException( "foo" );
>         }
>         @GET
>         @Path( "/bar" )
>         @Produces( "text/plain" )
>         public void bar( @Suspended final AsyncResponse response ) {
>             throw new RuntimeException( "bar" );
>         }
>     }
> }
> {code}
> curl localhost:8888/foo hangs forever; curl localhost:8888/bar does not.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message