cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6357) request matching on method matching issue with compareSortedConsumesMediaTypes
Date Mon, 20 Apr 2015 12:29:58 GMT

    [ https://issues.apache.org/jira/browse/CXF-6357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14502715#comment-14502715
] 

Sergey Beryozkin commented on CXF-6357:
---------------------------------------

Sorry, I was too fast with my earlier comment.

'qs' is not supposed to be used with Consumes. 'q' and 'qs' are tools to do the negotiation
of the content to be returned to a client.

See

https://java.net/projects/jax-rs-spec/lists/jsr339-experts/archive/2013-05/message/42

This test needs to be challenged.


> 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
>             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)

Mime
View raw message