users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Re: FilterAction and FilterContext

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 29 Nov 2011 11:03:25 -0500

On 11/29/11 10:47 AM, Sergey Beryozkin wrote:
> On 29/11/11 15:39, Marek Potociar wrote:
>> That's another viable option IMO.
>>
>> Although I still prefer the filter to actively return the continuation
>> as it's more in line with the simpler, functional
>> programming style (like it or not, JAX-RS filter IS a function) as
>> well as because I find it personally more robust,
>> readable and less error prone (as it eliminates potential
>> illegal/unintended context states) e.g.:
>>
>> public void preFilter(ctx) {
>>
>> if (stop) {
>> context.stop(response);
>> // bug - forgot the return
>> }
>>
>> context.continue(request);
>> // what now? is the above going to produce an exception or just continue?
>> }
>
> The whole idea about using an input parameter to indicate a course of
> action is just a broken, broken, broken idea, apologies for getting into
> the loop here.

I agree. Whenever I see myself with a method returning a State enum I
feel I've done something wrong and the method needs to be refactored.

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