[jax-rs-spec users] [jsr339-experts] Re: Null response entity and writer providers

From: Sergey Beryozkin <>
Date: Wed, 13 Mar 2013 22:14:58 +0000

On 13/03/13 14:27, Sergey Beryozkin wrote:
> On 13/03/13 14:25, Marek Potociar wrote:
>> I'd say that if there is no entity produced, no writers are invoked
>> and thus no writer interceptors are invoked. That's analogous to
>> processing empty inbound messages where the user does not try to
>> inject or read the entity.
> That sounds OK, agreed
What should ContainerResponseContext return in case of the null response
body and the resource method actually invoked, for example,

public Book getBook() {
     throw new SomeException();

Mapper: maps it to Response with a null entity.

The filters are processing this response, should they return 'null' for
ContainerResponseContext for getEntityClass/Type/Annotations, or the
actual Book type info ?
I think it should be 'null' but as usual would appreciate that it is
indeed the case

> Cheers, Sergey
>> Marek
>> On Mar 13, 2013, at 2:38 PM, Sergey Beryozkin<>
>> wrote:
>>> Hi
>>> If we have a null response entity (example, with "void" resource
>>> method return types or Response having no entity set), do writer
>>> interceptors still get a chance to change it ? I think yes,
>>> WriterInterceptorContext has a setEntity() method,
>>> but given WriterInterceptor chain delegates eventually to
>>> MessageBodyWriter, I wonder what is the right answer there.
>>> I guess the runtime should indeed let the writers process Response
>>> with the empty entity, but stop short of delegating to
>>> MessageBodyWriter if the response entity is null...
>>> Sergey