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

Wildcard breaks method binding specified by @Produces


    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.RC1
    • 2.1.0.GA
    • jaxrs
    • None

      The following example shows the issue.

      There are 3 methods for accept header matching for application/xml, application/json, */*.

      	public Obj getObj(........);
      	public Obj getObjAsXml(........);
      	public Obj getObjAsJson(........);
      • Given accept header: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        • Expected:
          • It should match to getObjAsXml() based on HTTP spec.
          • "application/xml" has higer priority than "*/*" for given accept header.
        • Actual:
          • It matches to getObj() instead.
            • line 180 of org.jboss.resteasy.core.registry.Segment.java
                    for (WeightedMediaType accept : accepts)
                       for (WeightedMediaType produce : produces)
                          if (accept.isCompatible(produce)) return producesMap.get(produce);
            • It binds to "*/*" instead of "application/xml" because of following situation.
              • the first "accept" object is "text/html"
              • the first "produce" object is "*/*".
              • "text/html".isCompatible("*/*) return true. As a result, it binds to wrong method.

            patriot1burke@gmail.com Bill Burke (Inactive)
            osbornchan_jira Osborn Chan (Inactive)
            0 Vote for this issue
            2 Start watching this issue