Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-13985

[GSS](7.1.z) RESTEasy is selecting the wrong variant

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 7.0.6.GA
    • REST
    • Hide

      mvn clean verify -Djboss.home=PATH_TO_EAP

      Show
      mvn clean verify -Djboss.home=PATH_TO_EAP

    Description

      RESTeasy is selecting the wrong variant. Let's say we have the following JAX-RS resource method:

      @Path("/")
      public class WrongParamResource {
      
      	final List<Integer> body = Arrays.asList(1, 2, 3, 4, 5, 6);
      	
      	@GET
      	public Response variants() {
      		final List<Variant> variants = Variant
      				.mediaTypes(MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE, MediaType.TEXT_PLAIN_TYPE)
      				.build();
      		return Response.ok(body).variants(variants).build();
      	}
      
      }
      

      It works if we ask for a specific content type:

      $ curl  -H 'Accept: application/json' http://localhost:8080/resteasy-wrong-variant
      [1,2,3,4,5,6]
      

      But it fails when we use / accept header (it should select JSON):

      $ curl  -H 'Accept: */*' http://localhost:8080/resteasy-wrong-variantCould not find MessageBodyWriter for response object of type: java.util.Arrays$ArrayList of media type: application/octet-stream
      

      It should select application/json. When we apply the fix from JBEAP-10916 the issue is different, but still, it will not select the correct variant. See below it should select text/plan, but instead returns a 406 error:

      $ curl  -H 'Accept: text/*,*/*' -v  http://localhost:8080/resteasy-wrong-variant* About to connect() to localhost port 8080 (#0)
      *   Trying ::1...
      * Connection refused
      *   Trying 127.0.0.1...
      * Connected to localhost (127.0.0.1) port 8080 (#0)
      > GET /resteasy-wrong-variant HTTP/1.1
      > User-Agent: curl/7.29.0
      > Host: localhost:8080
      > Accept: text/*,*/*
      > 
      < HTTP/1.1 406 Not Acceptable
      < Connection: keep-alive
      < X-Powered-By: Undertow/1
      < Server: JBoss-EAP/7
      < Content-Length: 0
      < Date: Thu, 22 Jun 2017 02:48:59 GMT
      < 
      * Connection #0 to host localhost left intact
      

      This issue should be fixed by: https://issues.jboss.org/browse/RESTEASY-994

      Attachments

        Issue Links

          Activity

            People

              thofman Tomas Hofman
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: