jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Interceptor filter exception handling

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 14 May 2012 22:28:35 +0200

On May 12, 2012, at 4:47 PM, Bill Burke wrote:

> On 5/11/12 4:32 PM, Sergey Beryozkin wrote:
>> By the way, how does the exception flow works, starting from MBR
>> throwing an exception ? Will Reader interceptors get the exception ?
>> Is it important for filters to get this exception to clear whatever
>> state they may have prepared for the reader interceptors ?
>>
>
> * Interceptors wrap so you can have try/catch blocks there
> * For filters they don't wrap and have no callback (whether or not things succeed), so they must be self-contained irregardless of success or failure as there is no way to clean up any state.
>
> You could have Filters wrap:
> * wrap around write of request on client side
> * wrap around call to resource method on server
> * wrap around write of response on server
>
> BUT....because reading the response on the client comes in two stages (invoke() and getEntity()) wrapping is much more problematic.
>
> So, if somebody believes filters need the ability to cleanup on success or failure, then IMO, a callback is the best approach.

+1 - if we need that, we should introduce callback.

Marek

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