Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1867

ContainerResponseFilter not fired for SSE endpoint

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: jax-rs-whiteboard-1.0.2
    • Fix Version/s: None
    • Component/s: jax-rs-whiteboard
    • Labels:
      None

      Description

      I have a resource class such as the following:

      @Path("events")
      @JaxrsResource
      public class EventsResource {
      
        private Sse sse;
        private SseBroadcaster eventBroadcaster;
      
        @Context
        public void setSse(Sse sse) {
          this.sse = sse;
          this.eventBroadcaster = sse.newBroadcaster();
        }
      
        @GET
        @Produces(MediaType.SERVER_SENT_EVENTS)
        public void suscribeToEvents(@Context SseEventSink eventSink) {
          eventBroadcaster.register(eventSink);
        }
      }
      
      

       

       

      In addition, I have a CORS filter:

       

      @Component(immediate=true)
      @Provider
      @JaxrsExtension
      public class CORSFilter implements ContainerResponseFilter {
      
        @Override
        public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
          System.out.println("CORSFilter for "+requestContext.getUriInfo().getPath());
          MultivaluedMap<String, Object> headers = responseContext.getHeaders();
      
          headers.add("Access-Control-Allow-Origin", requestContext.getHeaderString("Origin"));
          ...
      
      

       

      The CORS filter gets fired on all requests as I expect, except for ones to the EventResource.subscribeToEvents method. Hence browsers complain when receiving SSE events.

      This used to work fine with jersey as the JAXRS implementation. CORS filter got called for the EventsResource.subscribeToEvents call.

      I've no idea whether this is a jaxrs-whiteboard level issue, or a CXF level issue. I will try and come up with a plain CXF test of the same thing for comparison.

       

        Attachments

        1. CORSFilter.java
          0.5 kB
          Tom Quarendon
        2. make.out
          14 kB
          Tom Quarendon
        3. make2.out
          43 kB
          Tom Quarendon
        4. Server.java
          2 kB
          Tom Quarendon
        5. TestService3.java
          0.3 kB
          Tom Quarendon

          Activity

            People

            • Assignee:
              csierra Carlos Sierra
              Reporter:
              tomq42 Tom Quarendon
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: