users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Global post match ContainerRequestFilter and subresources

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 25 Mar 2015 14:35:42 +0000

Sorry for the noise,
On 25/03/15 13:06, Sergey Beryozkin wrote:
> The user has reported that his experiments with Jersey have shown that
> in the below case Jersey invokes a global post-match
> ContainerRequestFilter once but ContainerResponseFilter twice.
>
That was related to an exception being mapped and Response passed
through the chain again, so no confusions there.

I'm fine with updating CXF for a global post-match filter invoked once,
only when the final resource method is invoked.

Do you think we need to have a minor documentation enhancement request
here (re ContainerRequestFilter) ? Example, explicitly note that global
filters do not apply when a subresource method is invoked but only when
the final resource method is invoked ?

Cheers, Sergey

> For the record, CXF invokes ContainerRequestFilter twice and
> ContainerResponseFilter once.
>
> I guess invoking a global ContainerResponseFilter twice in a case below
> is consistent with my reasoning that such a filter has a wild-card
> name-binding.
>
> Should it be (as far as global request response filters are concerned in
> the below example):
>
> ContainerRequestFilter: twice
> ContainerResponseFilter: twice
>
> ?
>
> Cheers, Sergey
>
> On 25/03/15 12:35, Sergey Beryozkin wrote:
>> Hi All
>>
>> I've had a user query and I'm reviewing the documentation at [1] and I'm
>> actually not sure if I understand it completely.
>>
>> Right now, CXF will run the same global post-match
>> ContainerRequestFilter twice with the following service class:
>>
>> @Path("rs")
>> public RSService {
>> @Path("sub")
>> public RSService sub() {
>> return this;
>> }
>> @Path("resource")
>> @GET
>> public Response get() {
>> //
>> }
>>
>> }
>>
>> and
>>
>> GET /rs/sub/resource
>>
>> once for the sub() method, and once for the get() method.
>>
>> I vaguely suspect it might be wrong, but the docs at [1] mention that
>> both resource and subresource methods can be invoked when Name Bindings
>> are used and in case of a global filter it is effective a wildcard name
>> binding.
>>
>> Marek, Santiago, can you please be nice (as you always are :-)) and
>> clarify: how many times a global filter is expected to be called in the
>> above case, 1 or 2 ?
>>
>> Thanks, Sergey
>>
>> [1]
>> https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/container/ContainerRequestFilter.html
>>
>>
>>
>>
>