[resteasy-dev] RESTEasy and need of Accept header
Jim Ma
ema at redhat.com
Wed Oct 11 22:51:00 EDT 2017
Sure. Alessio. I already filed a jira for this :
https://issues.jboss.org/browse/RESTEASY-1733
Will back to look at this later. Thanks for reporting this, Rostislav.
Cheers,
JIm
On 10/11/2017 09:56 PM, Alessio Soldano wrote:
> Thanks Rostislav.
> We've been mentioning this briefly with Jim on IRC this morning. It
> looks like a bug in the way SSE is turned on on server side as a
> consequence of the specified acceptable media types, which clearly
> come from the accept header in the request.
> So, I've performed a preliminary analysis, I think the
> SseEventSinkInterceptor should avoid relying on the acceptable media
> types; instead it should be going through the container request
> context (which should be a PostMatchRequestContext instance in that
> case, given there's no @PreMatching annotation), extract the
> ResourceMethodInvoker instance from that and finally get access to the
> corresponding matched resource method/class. Those would then be used
> to look for @Produces(MediaType.SERVER_SENT_EVENTS) and enable SSE.
> Jim, can you work on this please?
> Thanks
> Alessio
>
> On Wed, Oct 11, 2017 at 10:26 AM, Rostislav Svoboda
> <rsvoboda at redhat.com <mailto:rsvoboda at redhat.com>> wrote:
>
> Hi.
>
> I played a bit with SSE, example based on
> https://www.youtube.com/watch?time_continue=8&v=qQLVCgmiMgQ
> <https://www.youtube.com/watch?time_continue=8&v=qQLVCgmiMgQ>
> Code is here
> https://github.com/rsvoboda/rsvoboda-playground/tree/master/ee8-sample-sse
> <https://github.com/rsvoboda/rsvoboda-playground/tree/master/ee8-sample-sse>
>
> For GlassFish 5 I could do just: curl -i
> http://localhost:8080/ee8-sample-sse/resources/beats
> <http://localhost:8080/ee8-sample-sse/resources/beats>
>
> But for WF I had to specify Accept header: curl -i -H "Accept:
> text/event-stream"
> http://localhost:8080/ee8-sample-sse/resources/beats
> <http://localhost:8080/ee8-sample-sse/resources/beats>
> When I used curl command which was working on GlassFish 5 I
> received pretty nasty NPE stacktrace.
>
> These days people are playing quite a lot with new stuff in EE8,
> they are using GlassFish 5 and composing their clients (Java,
> JavaScript, curl / libcurl ) based on this experience (who reads
> the spec ? when you have RI you can trust;) ).
> RESTEasy requirement on Accept header can be pain you_know_where
> for migration towards JBoss world.
>
> For sure the error message should be more user friendly and more
> descriptive.
> And I would also vote for more RI like behavior in this case. WDYT ?
>
>
> NPE details:
> Error processing request
> Context Path:
> /ee8-sample
>
> Servlet Path:
> /resources
>
> Path Info:
> /beats
>
> Query String:
> null
>
> Stack Trace
> org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException:
> java.lang.NullPointerException
> org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:78)
> org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:222)
> org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:183)
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:444)
> org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$1(SynchronousDispatcher.java:219)
> org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:132)
> org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:367)
> org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:135)
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:205)
> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227)
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
> io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
> io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
> org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
> io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
> io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
> io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
> io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
> io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
> io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
> io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
> io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
> io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
> io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
> io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
> io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
> io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> java.lang.Thread.run(Thread.java:748)
>
>
>
> Rostislav
>
> _______________________________________________
> resteasy-dev mailing list
> resteasy-dev at lists.jboss.org <mailto:resteasy-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/resteasy-dev
> <https://lists.jboss.org/mailman/listinfo/resteasy-dev>
>
>
>
>
> _______________________________________________
> resteasy-dev mailing list
> resteasy-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/resteasy-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/resteasy-dev/attachments/20171012/f97fc300/attachment-0001.html
More information about the resteasy-dev
mailing list