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

[GSS](7.0.z) RESTEASY-1227 - MediaType set incorrectly in SegmentNode when multiple media types are offered.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.7.CR1, 7.0.7.GA
    • None
    • REST
    • None
    • EAP 7.0.7

      When a client offers multiple media types in an Accept header, for example, Accept: text/html, image,jpg, text/json, *

      https://github.com/resteasy/Resteasy/blob/3.0.10.Final/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/registry/SegmentNode.java#L430 selects the most specific type and places it as an attribute without taking into consideration the MessageBodyWriters available.

      When the type is retrieved in https://github.com/resteasy/Resteasy/blob/3.0.10.Final/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ServerResponseWriter.java#L129 it is only the best type chosen previously, irrespective of current MessageBodyWriters available.

      If I have a resource that can return different object types, for example, String & JsonObject. and in this case, my endpoint returns returns a JsonObject, I will get an error similar to:

      Could not find MessageBodyWriter for response object of type: org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl of media type: text/html

      There isn't a writer registered for text/html but there is one for text/json, which would have been handled by the text/json or *

        1. SegmentNode.java
          18 kB
        2. ServerResponseWriter.java
          16 kB
        3. Test1227c.java
          6 kB

            rsigal@redhat.com Ronald Sigal
            rhn-support-bmaxwell Brad Maxwell
            Peter Mackay Peter Mackay
            Peter Mackay Peter Mackay
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: