users@jersey.java.net

Re: [Jersey] Question to correct URI-mapping behaviour

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 27 Jan 2010 11:39:08 -0500

On Jan 27, 2010, at 10:59 AM, Daniel Bimschas wrote:
>
> I have a question regarding the correct mapping of URIs to JAX-RS methods. We have an implementation class that provides two methods as follows:
>
> @GET
> @Path("abc/{var}")
> public Response getAbc(@PathParam("var") var) { ... }
>
> @GET
> @Path("abc/{var}.xml")
> public Response getAbcAsXML(@PathParam("var") var) { ... }
>
> The JAX-RS specification says in 3.7.2 Request Matching under "3. Identify the method that will handle the request":
>
> "(c) The request is dispatched to the first Java method in the set5."
>
> While a set has no order this seems to be implementation dependent and/or "non-deterministic". Is this correct?
>
> As I suppose both methods are valid candidates for the set mentioned in the spec I wonder which method should be chosen. The problem (which is why I ask) is that Jersey choses getAbc(...) while the Apache CXF implementation choses getAbcAsXML(...) obviously interpreting the "something.xml" in the URI as the value for the path parameter. Is there a way to tell which behaviour is correct? Has one of the implementations a bug?
>
I would expect both implementations to use getAbcAsXML since step 2.(h) only includes methods with the best matching URI template. I think this may be a bug in Jersey.

Marc.