users@jax-rs-spec.java.net

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

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 25 Feb 2014 13:41:31 +0000

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