users@jax-rs-spec.java.net

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

From: Markus KARG <markus_at_headcrashing.eu>
Date: Tue, 25 Feb 2014 18:28:51 +0100

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