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

[jsr339-experts] Interceptor filter exception handling

From: Bill Burke <bburke_at_redhat.com>
Date: Sat, 12 May 2012 10:47:10 -0400

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.


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