users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Corner case in URI matching

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 5 Mar 2014 15:58:48 +0000

Bill, the same issue is reported against RestEasy,

I'm not it is a spec issue now that at least 2 implementations can catch
a matrix parameter in certain cases...May be it is

Sergey
On 03/03/14 11:33, Sergey Beryozkin wrote:
> well, if we prepare the path in advance and strip it off the matrix
> parameters then we will have
>
> either
> /people
> or
> /people/
>
> and in both cases getAll() will be matched.
>
> In CXF, the handling of the matrix parameters is done 'lazily', i.e,
> it's a 10% case, so only if no match has been successful then does CXF
> retry with a 'pure' path without the matrix parameters submitted for the
> match; but looks like it is not quite right, the side-effect should not
> really happen, I'm coming to the conclusion it is a CXF issue
>
> Thanks, Sergey
>
> On 25/02/14 17:28, Markus KARG wrote:
>> Actually I would have assumed that the semicolon is detected as an
>> end-of-path separator, hence getPerson to be matched for the second case.
>>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin_at_talend.com]
>> Sent: Dienstag, 25. Februar 2014 14:42
>> To: jsr339-experts_at_jax-rs-spec.java.net
>> Subject: [jsr339-experts] Corner case in URI matching
>>
>> Hi All, how are things,
>>
>> I've just had to deal with what appears to be a corner case in the way
>> URI
>> is matched:
>>
>> @Path("/people/")
>> public class Root {
>> @GET
>> @Path("/")
>> public Response getAll() {...}
>>
>> @GET
>> @Path("/{id}/")
>> public Response getPerson(@PathParam("id") long id) {...}
>>
>> }
>>
>> GET /people;a=b
>>
>> selects getAll()
>>
>>
>> GET /people/;a=b
>>
>> selects Root and "/;a=b" is used to match the method, both getAll &
>> getPerson match it, getPerson is preferred, catches ";a=b" as a template
>> parameter value, the exception is thrown when converting it to long.
>>
>> Restricting getPerson to "@Path("/{id:(\d)+}/")" fixes the problem.
>>
>> Is there any reason the specification can not require that ";" is
>> explicitly
>> forbidden in the default expression matching a given template var such as
>> "{id}" ?
>>
>> Sergey
>>
>
>


-- 
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com