Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1431

Error in the JAX-RS implementation for matching method types to Accept Header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1
    • 2.1
    • JAX-RS
    • None
    • Moderate

    Description

      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 in the CXF implementation the application/json one is invoked. Suggest changing the algorithm to:

      1. Sort the Accept header according to the W3 standards
      2. Iterate through the accept header list. For each one:
      1. Find all matching methods
      2. If there is only one method return this and break out of the accept header loop
      3. If there are multiple methods sort these methods using consume mime and produce mime. Then return the first

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              barfitzgerald Barry Fitzgerald
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: