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

Enabling Sse on server side swallow filters exceptions


      Let's consider a JAX-RS application configured with both a Sse resource and a ContainerRequestFilter as follow:

      	public static class ExceptionRequestFilter implements ContainerRequestFilter {
      		public void filter(ContainerRequestContext containerRequestContext) throws IOException {
      			throw new IOException();

      On processing an incomming Sse request for the registered Sse resource, the org.jboss.resteasy.plugins.providers.sse.SseEventSinkInterceptor will be invoked and will register a org.jboss.resteasy.plugins.server.servlet.Cleanable in charge of returning the initial Sse response when resource method returns as stated by the spec in chapter 9.5 Processing Pipeline.
      Then the registered ExceptionRequestFilter will be invoked and will throw an IOException.

      I was expecting this exception to be propagated to the client side through an InternalServerErrorException but instead, because of the registered org.jboss.resteasy.plugins.server.servlet.Cleanable a 200 ok response will be sent to the client.

      Another issue with the org.jboss.resteasy.plugins.server.servlet.Cleanable regsitered by the
      org.jboss.resteasy.plugins.providers.sse.SseEventSinkInterceptor is that with a servlet that does not support Asynch mechanims, if resource methods return first, I mean before any Sse event has been sent, then the initial response will never be thrown since the cleanables will only be invoked once thread will be released.

            rhn-support-asoldano Alessio Soldano
            nicones Nicolas NESMON (Inactive)
            0 Vote for this issue
            1 Start watching this issue