cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Fitzgerald" <barfitzger...@gmail.com>
Subject JAX-RS Support: Error in the JAX-RS specs for matching method types?
Date Mon, 11 Feb 2008 13:23:28 GMT
Hi all,

I think there is an error in the algorithm in the JAX-RS specs for choosing
the resource method (see bullet 2. in section 2.6)

Consider the following scenario:

I have a resource with 2 methods:

@HttpMethod("GET")
@UriTemplate("/users/{id}")
@ProduceMime("text/xml")
public Response getUser(@UriParam("id") String id) throws Exception { ....}

@HttpMethod("GET")
@UriTemplate("/users/{id}")
@ProduceMime("application/json")
public Response getUserJSON(@UriParam("id") String id) throws Exception {
....}

If I then send a request to /users/24 with Accept headers of  "text/xml,
*/*" one would expect the "text/xml" method to be invoked. However following
the algorithm in the spec it is undefined which method should be invoked.

More details:

In the algorithm, both methods match the accept headers i.e. they are both
added to the list of "matching resource methods" This list is then sorted
using the consume mime type (not relevant in this case) and then by the
produce mime. In this case it will compare "text/xml" against
"application/json". As both are equally specific it is undefined which
should be first. (The current version of CXF trunk sorts application/json to
the top of the list)

However surely as the "text/xml" method matches the accept header
specifically it should always be returned first? See -
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for further details

I think this is an error in the spec (not how it's been implemented in CXF).


Can anyone confirm if I've made any mistakes in my reasoning?

Barry

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message