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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.0.0.CR3
    • 4.0.0.CR2
    • None
    • None

    Description

      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".

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: