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

When choosing return media type, don't ignore MessageBodyWriters without @Produces annotation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 3.6.3.SP1
    • None
    • None

      After org.jboss.resteasy.core.ServerResponseWriter.getDefaultContentType() collects all MessageBodyWriters for which isWriteable() returns true, it checks their @Produces values against the media types in the Accept header. However, if a given MBW doesn't have a @Produces annotation, it is ignored. If no MBWs with matching @Produces are found, getDefaultContentType() goes on to select a media type from the Accept header.

      Here's the problem. Suppose the Accept header is

      Accept: isnt/writeable, is/writeable;q=0.9
      

      Then "isnt/writeable" will be chosen, for which (presumably) there isn't a MBW, and "is/writeable", for which (presumably) there is a MBW, will be ignored. The result will be 500 exception stating a MBW can't be found for "isnt/writeable".

              rsigal@redhat.com Ronald Sigal
              rsigal@redhat.com Ronald Sigal
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: