There's really not anything you can do about this at the Resteasy/JAX-RS 
level.  Buffering responses can also be VERY BAD for performance so 
Resteasy (and really JAX-RS) writes directly to the network output 
stream when marshalling via Jackson.

Depending on what servlet container you are using, you may be able to 
configure it to buffer responses so that if an exception is thrown in 
serialization the response can be reset.

On 11/30/2013 12:52 PM, Przemyslaw Wesolek wrote:
> Hello,
>
> I'm exposing my application via RESTEasy 3.0.5Final with Jackson JSON
> provider. The serialization is still being written, so sometimes bugs
> creep out. Most often it is some exception being thrown by the Jackson
> serializer.
>
> However, at the moment it happens, the response is already commited,
> status code set to 200 and partial response is being written to the
> output. This is Very Bad Thing, as from the client perspective the 200
> status code means everything went OK, but the JSON is broken.
>
> For example, if the Jackson can't serialize field "abc", the resulting
> JSON looks like:
>
>> {
>>    // some fields serialized correctly by Jackson, like:
>>    "ok_field": 1,
>>    // ...
>>    // and then the erronous one, the name without a value:
>>    "abc"}
>
>
> This is because of the setStatus() call being in ServerResponseWriter in
> line 70:
>
>>        response.setStatus(jaxrsResponse.getStatus());
>
> while the serialization (and an exception throw) being in line 99:
>
>>        writerContext.proceed();
>
> Is there any way I can defer committing anything in the response until
> the whole response body is prepared?
>
> Regards,
> Przemek
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to