aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markus Rathgeb (Jira)" <j...@apache.org>
Subject [jira] [Comment Edited] (ARIES-1968) SSE breaks Pipeline Processing
Date Fri, 31 Jan 2020 16:22:00 GMT

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

Markus Rathgeb edited comment on ARIES-1968 at 1/31/20 4:21 PM:
----------------------------------------------------------------

Hi Carlos,

I am a little bit irritated.

If your test case succeed (the aotmic integer that tracks the ContainerResponseFilter call
is increased twice) and my test case (not yet an automatic one) fails, then I assume that
one of the both test cases is not correct. If yours is working, then I don't need to create
an issue for CXF but need to find the issue in my code base.

If my code base is correct, then we -need- could try to detect the error in your test code
first.

If there is an test case that runs without user interaction that shows the error (if there
is any) then we could give CXF a better mechanism to reproduce it...

I will now read ARIES-1867 and check what is already answered.

Thank you


was (Author: maggu2810):
Hi Carlon,

I am a little bit irritated.

If your test case succeed (the aotmic integer that tracks the ContainerResponseFilter call
is increased twice) and my test case (not yet an automatic one) fails, then I assume that
one of the both test cases is not correct. If yours is working, then I don't need to create
an issue for CXF but need to find the issue in my code base.

If my code base is correct, then we -need- could try to detect the error in your test code
first.

If there is an test case that runs without user interaction that shows the error (if there
is any) then we could give CXF a better mechanism to reproduce it...

I will now read ARIES-1867 and check what is already answered.

Thank you

> SSE breaks Pipeline Processing
> ------------------------------
>
>                 Key: ARIES-1968
>                 URL: https://issues.apache.org/jira/browse/ARIES-1968
>             Project: Aries
>          Issue Type: Bug
>          Components: jax-rs-whiteboard
>    Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.7, jax-rs-whiteboard-1.0.6
>            Reporter: Markus Rathgeb
>            Priority: Major
>
> The JAX-RS Specification 2.1 contains the chapter 9 for "Server-Sent Events".
> The chapter 9.5 "Pipeline Processing" declares:
> {quote}For compatibility purposes, implementations MUST initiate processing of an SSE
response when either the first message is sent or when the resource method returns, whichever
happens first. The initial SSE response, which may only include the HTTP headers, is processed
using the standard JAX-RS pipeline as described in Appendix C. Each subsequent SSE event may
include a different payload and thus require the use of a specific message body writer. Note
that since this use case differs slightly from the normal JAX-RS pipeline, implementations
SHOULD NOT call entity interceptors on each individual event (1).
> {quote}
> So, the initial SSE response is processes using the standard JAX-RS pipeline (Appendix
C).
> Appendix C indicates that in front of the method invocation the "Container Request Chain"
is handled and after the method invocation the "Container Response Chain" is handled.
>  
> The container response chain is currently not handled for the first response!
> It is also not handled for the other reponses, but this is expected.
>  
> I checked v1.0.5, v1.0.6 and v1.0.7 all seems to be broken for me.
>  
> h2. Test code:
>  
> {code:java}
> @Component(service = Application.class)
> @JaxrsName("rest")
> @JaxrsApplicationBase("rest")
> public class RESTApplicationImpl extends Application {
> }{code}
>  
>  
> {code:java}
> @Component(service = { RESTResource.class })
> @JaxrsResource
> @JaxrsName("foo")
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=rest)")
> @Path("/foo")
> public class RESTResource {
> @GET
>  @Path("normal")
>  public Response normal() {
>  System.out.println("handle endpoint \"normal\"");
>  return Response.ok().build();
>  }
> @GET
>  @Path("sse")
>  @Produces(MediaType.SERVER_SENT_EVENTS)
>  public void sse(@Context final SseEventSink eventSink, @Context final Sse sse) {
>  System.out.println("handle endpoint \"sse\"");
>  final ExecutorService executor = Executors.newSingleThreadExecutor();
>  executor.execute(() -> {
>  try (SseEventSink sink = eventSink) {
>  eventSink.send(sse.newEvent("event1"));
>  eventSink.send(sse.newEvent("event2"));
>  }
>  });
>  executor.shutdown();
>  }
> }
> {code}
>  
>  
> {code:java}
> @Component
> @JaxrsExtension
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=rest)")
> public class SimpleRequestFilter implements ContainerRequestFilter {
> @Override
>  public void filter(final ContainerRequestContext context) {
>  System.out.println("simple request filter");
>  }
> }
> {code}
>  
>  
> {code:java}
> @Component
> @JaxrsExtension
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=rest)")
> public class SimpleResponseFilter implements ContainerResponseFilter {
> @Override
>  public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext
responseContext)
>  throws IOException {
>  System.out.println("simple response filter");
>  }
> }
> {code}
>  
>  
> h2. Test:
> On a GET request to "http://127.0.0.1:8080/rest/foo/normal" is see (on the server console):
>  
> {noformat}
> simple request filter
> handle endpoint "normal"
> simple response filter{noformat}
>  
> On a GET request to "http://127.0.0.1:8080/rest/foo/sse" is see (on the server console): 
> {noformat}
> simple request filter
> handle endpoint "sse"{noformat}
>  
> As the normal processing pipeline must be applied for the first SSE reponse I would expect
"simple response filter" is shown once, too.
>  
> In my application there is a ContainerResponseFilter to allow (configurable) CORS. If
it is enabled, the headers that allow the cross-origin access are added.
> This needs to be added to the initial header (first response) of the SSE connection,
too.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message