You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2013/08/29 12:10:52 UTC

[jira] [Resolved] (CXF-5240) Jsonp interceptors do not work with GZIPOutInterceptor

     [ https://issues.apache.org/jira/browse/CXF-5240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-5240.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.7.7
                   2.6.10
                   3.0.0
         Assignee: Sergey Beryozkin

Thanks for finding out how to fix it. I updated the code for the message OS checked first; 

Note that CXF 2.5.x line is not supported any longer, please migrate to CXF 2.6.10 or CXF 2.7.7 - to be released shortly
                
> Jsonp interceptors do not work with GZIPOutInterceptor
> ------------------------------------------------------
>
>                 Key: CXF-5240
>                 URL: https://issues.apache.org/jira/browse/CXF-5240
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS, Transports
>    Affects Versions: 2.5.9
>            Reporter: Vadim Beilin
>            Assignee: Sergey Beryozkin
>             Fix For: 3.0.0, 2.6.10, 2.7.7
>
>
> Jsonp support via Jsonp(In,PreStream,PostStream)Interceptor (as described in http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-JSONWithPadding%28JSONP%29) conflicts with GZIPOutInterceptor.
> With a very simple test application request "http://localhost:7543/12?_jsonp=abc" without Gzip results in the following response 
> bq. abc(24);
> With Gzip:
> bq. abc();24
> Apparent reason is that the method org.apache.cxf.jaxrs.provider.jsonp.AbstractJsonpOutInterceptor.writeValue(Message, String) writes directly to the response output stream. When the method is changed to write to {{message.getContent(OutputStream.class)}}, responses with and without Gzip interceptor become the same "abc(24);", as expected.
> ------------------------
> Service code:
> {code}
> package test.cxf.jsonp;
> import javax.ws.rs.*;
> @Path("/") @Produces("application/json")
> public class Service {
>     @GET @Path("{id}") public int find(@PathParam("id") int id) {
>         return id * 2;
>     }
> }
> {code}
> Configuration (with Gzip)
> {code}
> <jaxrs:server id="jsonp" address="http://localhost:7543/">
>     <jaxrs:serviceBeans>
>       <ref bean="serviceBean" />
>     </jaxrs:serviceBeans>       
>     <jaxrs:inInterceptors>
>        <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpInInterceptor"/>
>        <bean class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor"/>
>     </jaxrs:inInterceptors>
>     <jaxrs:outInterceptors>
>        <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpPreStreamInterceptor"/>
>        <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpPostStreamInterceptor"/>
>        <bean class="org.apache.cxf.transport.common.gzip.GZIPOutInterceptor"/>
>     </jaxrs:outInterceptors> 
> </jaxrs:server>
> <bean id="serviceBean" class="test.cxf.jsonp.Service" />
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira