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

Request hangs if an ExceptionManager is used and a ContainerRequestFilter is used which throws an exception on an SSE resource

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 6.2.2.Final
    • None
    • None
    • None
    • Hide

      Create a deployment with the following examples:

      DefaultExceptionMapper.java
      @Provider
      public class DefaultExceptionMapper implements ExceptionMapper<Throwable> {
          @Override
          public Response toResponse(final Throwable exception) {
              return Response.serverError().entity(exception).build();
          }
      }
      
      ExceptionRequestFilter.java
      @Provider
      @Priority(Integer.MAX_VALUE)
      public class ExceptionClientRequestFilter implements ContainerRequestFilter {
      
          @Override
          public void filter(final ContainerRequestContext requestContext) throws IOException {
              throw new IOException("Thrown on purpose");
          }
      }
      
      SseResource.java
      @Path("/sse")
      public class SseResource {
      
          @GET
          @Produces(MediaType.SERVER_SENT_EVENTS)
          public void getEventSink(@Context SseEventSink sseEventSink) {
          }
      }
      

      Invoke the endpoint and see the hang.

      Show
      Create a deployment with the following examples: DefaultExceptionMapper.java @Provider public class DefaultExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse( final Throwable exception) { return Response.serverError().entity(exception).build(); } } ExceptionRequestFilter.java @Provider @Priority( Integer .MAX_VALUE) public class ExceptionClientRequestFilter implements ContainerRequestFilter { @Override public void filter( final ContainerRequestContext requestContext) throws IOException { throw new IOException( "Thrown on purpose" ); } } SseResource.java @Path( "/sse" ) public class SseResource { @GET @Produces(MediaType.SERVER_SENT_EVENTS) public void getEventSink(@Context SseEventSink sseEventSink) { } } Invoke the endpoint and see the hang.

    Description

      If a ContainerRequestFilter throws an error and has a @Priority(Integer.MAX_VALUE) an SSE resource will hang if an ExceptionMapper is used. This is likely similar to RESTEASY-1772.

      The SseEventSinkInterceptor is invoked before the custom ContainerRequestFilter. This suspends the ResteasyAsynchronousContext which is never completed. However, without an ExceptionMapper an exception is thrown and propagated up to the servlet container which will complete the jakarta.servlet.AsyncContext.

      Attachments

        Issue Links

          Activity

            People

              rsearls r searls
              jperkins-rhn James Perkins
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: