Sergey,

Thanks for looking into this.

I want to make sure I understand the solution.  It sounds like you made
a change to org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor so that
when the exception is caught, (perhaps around line 362,) you add a line
like this:


    HttpServletResponse response = (HttpServletResponse)
message.get(AbstractHTTPDestination.HTTP_RESPONSE);
    response.setStatus(status);

Is that right?

I just noticed you are making commits on CXF-4141 and it looks more
complicated than that.  :)  Maybe I'll wait for the next release.  I
have some time on this project.

Thanks again for the help.

Benji

-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]] 
Sent: Tuesday, February 28, 2012 7:05 AM
To: [email protected]
Subject: Re: response_code 500 ignored when set in
JAXRSOutInterceptor.handleWriteException

I resolved this by writing direct to the servlet response (in case of 
write failures),

Cheers, Sergey
On 27/02/12 22:23, Sergey Beryozkin wrote:
> Hi Benji
> On 27/02/12 19:47, Benji Shults wrote:
>> Glen,
>>
>> I'm using CXF 2.5.2. I haven't made any changes to
JAXRSOutInterceptor.
>> The only interceptors I've added are the built-in
>> LoggingIn/OutInterceptors.
>>
>> When JAXRSOutInterceptor calls writer.writeTo, that writer writes to
the
>> message's outputStream then throws an exception. Looking at the code
in
>> JAXRSOutInterceptor, I see that it does this:
>>
>> message.put(Message.RESPONSE_CODE, 500) // line 362
>>
>> However, my HTTP client sees a response code of 200.
>>
>> The writer I wrote myself and introduced it using the following:
>>
>> <jaxrs:providers>
>> <bean
>>
>>
class="com.ecologic.sdc.webservice.JsonUsageResponseValidatingProvider"
>> />
>> </jaxrs:providers>
>>
> If the response payload is not huge then consider buffering the
> response, see some information within this section:
>
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-
ConfiguringJAXBprovider
>
>
> that needs to be moved into the dedicated section though.
> If the provider is not JAXB-driven then having a
getEnablingBuffering()
> method returning 'true' on this provider will instruct the runtime to
> provide a CachedInputStream to the provider.
>
> Can you try it please ?
>
> Sergey
>
>
>
>
>> Benji
>>
>> -----Original Message-----
>> From: Glen Mazza [mailto:[email protected]]
>> Sent: Monday, February 27, 2012 1:39 PM
>> To: [email protected]
>> Subject: Re: response_code 500 ignored when set in
>> JAXRSOutInterceptor.handleWriteException
>>
>> Can you give a very generic version of that interceptor that would
>> duplicate/demonstrate the problem?
>>
>> Glen
>>
>> On 02/27/2012 02:36 PM, Benji Shults wrote:
>>> I have a scenario where the call to writer.writeTo in
>>> JAXRSOutInterceptor.serializeMessage throws an exception.
>>>
>>> Before throwing the exception, the writer writes to the message's
>>> outputStream.
>>>
>>> When write.writeTo throws the exception, handleWriteException calls
>>> message.put(Message.RESPONSE_CODE, 500).
>>>
>>> However, my HTTP client is seeing the response come back with HTTP
>>> response code 200.
>>>
>>> The following is appended to the response that the writer put into
the
>>> message's outputStream:
>>>
>>> Error serializing the response, please check the server logs,
response
>>> class : UsageResponse.
>>>
>>> Benji
>>>
>>
>>
>
>

Reply via email to