Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E2BDD17815 for ; Mon, 20 Apr 2015 12:29:58 +0000 (UTC) Received: (qmail 89121 invoked by uid 500); 20 Apr 2015 12:29:58 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 89084 invoked by uid 500); 20 Apr 2015 12:29:58 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 89073 invoked by uid 99); 20 Apr 2015 12:29:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2015 12:29:58 +0000 Date: Mon, 20 Apr 2015 12:29:58 +0000 (UTC) From: "Sergey Beryozkin (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-6357) request matching on method matching issue with compareSortedConsumesMediaTypes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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' Fix code for your refference: > int org.apache.cxf.jaxrs.utils.JAXRSUtils.compareSortedConsumesMediaTypes(List mts1, List mts2, MediaType ct) > public static int compareSortedConsumesMediaTypes(List mts1, List mts2, MediaType ct) { > List contentType = new ArrayList(); > contentType.add(ct); > List actualMts1 = intersectSortMediaTypes(mts1, contentType, true); > List 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)