Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-756

Client Framework does not handle parameter lists correctly

    XMLWordPrintable

Details

    Description

      The RESTEasy client framework fails to handle collection or array parameters correctly (query param, matrix param).

      Consider the following JAX-RS service interface:

      @GET
      @Path(value = "/myresource")
      @Produces(

      {"application/json; charset=UTF-8"}

      )
      MyResponse getMySomethingByIds(
      @MatrixParam("id")
      List<String> ids)

      The matrix param "id" is of type List<String>, so the parameter can be repeated any number of times to form a collection of strings. A GET URL for this resource could be the following: http://host/app/myresource;id=1;id=2;id=3

      This works fine with the RESTEasy server side framework. However, the client framework produces URLs like this: http://host/app/myresource;id=%5B1%2C%202%2C%203%5D

      The RestEasy client framework fails to notice that this is actually a collection of values and simply invokes the toString method of the collection, which leads to the invalid GET URL posted above.

      Upon receiving a request with such an URL the REST server (implemented with RESTEasy) produces the following error message:

      Unable to extract parameter from http request: javax.ws.rs.MatrixParam(\"id\") value is '[1, 2, 3]' for public abstract [... method signature omitted ...]

      My current low-level workaround is to put a comma separated list into a string and do the parsing manually as this seemed to be the simplest way to workaround this problem.

      Proposed fix:
      I think the method createRequest(Object[]) in org.jboss.resteasy.client.core.ClientInvoker should check if the argument is an array or a collection. If this is the case it should iterate over the array/collection and invoke marshallers[i].build(request, args[i]) for each single element.

      Additional information: There is a stackoverflow entry on the same topic which proposes a more sophisticated workaround using wrapper objects
      http://stackoverflow.com/questions/8860259/passing-a-list-or-array-to-resteasy-using-get

      Attachments

        Activity

          People

            rsigal@redhat.com Ronald Sigal
            achimbitzer_jira Achim Bitzer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: