What is the correct behavior when a JAX-RS method throws an exception that are 
not mapped by a ExceptionMapper and a ContainerResponseFilter is provided?

                @Path("/") @Produces(value = { MediaType.TEXT_PLAIN }) 
        public class ApiResources {
        
                @GET
                @Path("throwIllegalArgumentException")
                public String getThrowIllegalArgumentException() {
                        throw new IllegalArgumentException( "HELLO from 
throwIllegalArgumentException" );
        
        }

        @Provider
        public class MonitorFilter implements ContainerResponseFilter {
                @Override 
                 public void filter( ContainerRequestContext requestContext, 
                                 ContainerResponseContext responseContext ) 
throws IOException {
                        System.out.println(“Resource returned status=“ + 
responseContext.getStatus());
                }
        }
                
Tested the code in wildfly-8.0.0.Alpha4 and the ContainerResponseFilter#filter 
method was not called. It was only called after a ExceptionMapper for 
IllegalArgumentException was provided.

@Provider
public class IllegalStateExceptionExceptionMapper implements 
ExceptionMapper<IllegalStateException> {
        @Override
        public Response toResponse( IllegalStateException e ) {
                return Response.status( Response.Status.INTERNAL_SERVER_ERROR 
).entity( e.getMessage() )
                                .build();
        }
}

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to