[jax-rs-spec users] Re: [jsr339-experts] Re: HEADS-UP, IMPORTANT: Problems with JAX-RS interceptors

From: Bill Burke <>
Date: Mon, 30 Apr 2012 11:36:55 -0400

On 4/30/12 11:14 AM, Sergey Beryozkin wrote:
> On 30/04/12 16:05, Martin Matula wrote:
>> Hi Bill,
>> On 4/30/12 4:30 PM, Bill Burke wrote:
>>>> 2) readEntity() should make an implicit call to bufferEntity()
>>>> before it
>>>> does anything. This is just for filters! Not for reading in the
>>>> resource
>>>> method or the client.
>>> Just a thought..Maybe it shouldn't be implicit? Maybe the filter is
>>> reading the entity, then replacing it with writeEntity(), so a buffer
>>> is overkill? Or maybe its just better to protect the filter developer
>>> from himself? I don't know...
>> OK, not implicitly buffering may provide more flexibility. On the other
>> hand one poorly written filter can break everybody else. Not sure what's
>> better. I don't have a strong opinion on this one.
> IMHO it has to be optional. Wouldn't the buffering affect the
> well-written filters which replace the entity stream after doing
> readEntity ?
> I believe bufferEntity() needs to go from the api completely, but I
> guess it's off-topic for this thread

I see where you are coming from Sergy, but...

readEntity() of a byte array would return a set of uncompress (possibly
unencrypted too) bytes (possibly altered even more by an interceptor)
which is very different than a bufferEntity() that just buffers the
entire on-the-wire bytes.

The safest thing to do, IMO, is to have a buffereEntity() method that
just buffers the entire on-the-wire bytes.

> Cheers, Sergey
>>>> 3) maybe - remove get/setEntityStream() from filters (could not find a
>>>> use-case that could not be covered by interceptors or a combination of
>>>> an interceptor and a filter that triggers the interception by calling
>>>> bufferEntity()). Or maybe we want to keep it to be safe. Which
>>>> leaves us

On second thought, get/setEntityStream should remain. A
readEntity(InputStream) in Resteasy would return a GZIPInputStream if
the body was gzip encoded. Maybe thats not the rigth approach, but...


Bill Burke
JBoss, a division of Red Hat