[ https://issues.apache.org/jira/browse/CXF-6357?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Colm O hEigeartaigh closed CXF-6357. ------------------------------------ > request matching on method matching issue with compareSortedConsumesMediaTypes > ------------------------------------------------------------------------------ > > Key: CXF-6357 > URL: https://issues.apache.org/jira/browse/CXF-6357 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.0.3 > Environment: Windows > Reporter: Neal Hu > Assignee: Sergey Beryozkin > Fix For: 3.0.5 > > > The server side resource class and methods is: > @POST > @Consumes("text/xml;qs=0.7") > public String xml() { > return MediaType.TEXT_XML; > } > @POST > @Consumes("text/*") > public String postTextStar() { > return "text/*"; > } > The http request and response: > Method POST > Content-Type: text/xml > ------- > Response body: text/xml > According to Spec 3.7.2 Request Matching > 3. Identify the method that will handle the request: > (b)A total ordering can be defined over combined media types as follows. > When we compareSortedConsumesMediaType, need combine(intersect) the > contenttype and comuses first. So the response should be text/*. > Method xml->S(text/xml;qs=0.7, text/xml)=text/xml;qs=0.7 > Method postTextStart->S(text/*,text/xml)=text/xml > n1/m1=n2/m2 and v1=v2 and v1'<v2, postTextStart should be selected. > Fix code for your refference: > int > org.apache.cxf.jaxrs.utils.JAXRSUtils.compareSortedConsumesMediaTypes(List<MediaType> > mts1, List<MediaType> mts2, MediaType ct) > public static int compareSortedConsumesMediaTypes(List<MediaType> mts1, > List<MediaType> mts2, MediaType ct) { > List<MediaType> contentType = new ArrayList<MediaType>(); > contentType.add(ct); > List<MediaType> actualMts1 = intersectSortMediaTypes(mts1, > contentType, true); > List<MediaType> actualMts2 = intersectSortMediaTypes(mts2, > contentType, true); > int size1 = actualMts1.size(); > int size2 = actualMts2.size(); > for (int i = 0; i < size1 && i < size2; i++) { > int result = compareMediaTypes(actualMts1.get(i), > actualMts2.get(i), null); > if (result == 0) { > result = compareQualityAndDistance(actualMts1.get(i), > actualMts2.get(i), true); > } > if (result != 0) { > return result; > } > } > return size1 == size2 ? 0 : size1 < size2 ? -1 : 1; > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)