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 35E8F17545 for ; Wed, 1 Apr 2015 10:54:53 +0000 (UTC) Received: (qmail 48597 invoked by uid 500); 1 Apr 2015 10:54:53 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 48560 invoked by uid 500); 1 Apr 2015 10:54:53 -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 48546 invoked by uid 99); 1 Apr 2015 10:54:53 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 10:54:53 +0000 Date: Wed, 1 Apr 2015 10:54:52 +0000 (UTC) From: "Sergey Beryozkin (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-6307) Wrong select the message body reader 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-6307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14390348#comment-14390348 ] Sergey Beryozkin edited comment on CXF-6307 at 4/1/15 10:54 AM: ---------------------------------------------------------------- It is typed on Boolean, you have a Boolean class parameter in the signature - meaning you have a generic Boolean type. I've also mentioned that one does not have to provide explicit Consumes(text/plain) in the default provider for the spec requirement to be met, this is an implementation detail, a provider may have a check done in isReadable for example (CXF does not actually restrict it to text/plain only for Boolean - needs to be tuned too). I'm still investigating... was (Author: sergey_beryozkin): It is typed on Boolean, you have a Boolean class parameter in the signature - meaning you have a generic Boolean type. I've also mentioned that one does not have to provide explicit Produces(text/plain) in the default provider for the spec requirement to be met, this is an implementation detail, a provider may have a check done in isReadable for example (CXF does not actually restrict it to text/plain only for Boolean - needs to be tuned too). I'm still investigating... > Wrong select the message body reader > ------------------------------------ > > Key: CXF-6307 > URL: https://issues.apache.org/jira/browse/CXF-6307 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.0.3 > Environment: Windows > Reporter: Neal Hu > Fix For: 3.0.5 > > > This is a CTS testcase, the resource class is like this: > @POST > @Path("boolean") > public Boolean postBoolean(Boolean bool) { > if(bool){ > throw new WebApplicationException(Status.NOT_ACCEPTABLE); > } > return false; > } > The application provided provider is like this: > public class MyReader implements MessageBodyReader { > @Override > public boolean isReadable(Class type, Type type1, Annotation[] antns, MediaType mt) { > return type== Boolean.class; > } > @Override > public Boolean readFrom(Class type, > Type type1, > Annotation[] antns, > MediaType mt, MultivaluedMap mm, > InputStream in) throws IOException, WebApplicationException { > return Boolean.valueOf("true"); > } > } > The request > Content-Type:text/plain > Accept:text/plain > Method:POST > Body:false > According to jsr339 section 4.2.4 Standard Entity Providers java.lang.Boolean, java.lang.Character, java.lang.Number Only for text/plain. Corresponding primitive types supported via boxing/unboxing conversion. > An implementation MUST support application-provided entity providers and MUST use those in preference to its own pre-packaged providers when either could handle the same request. More precisely, step 4 in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer application-provided over pre-packaged entity providers. > 4.2.1 Message Body Reader > 3. Select the set of MessageBodyReader classes that support the media type of the request, see Section > 4.2.3. > 4. Iterate through the selected MessageBodyReader classes and, utilizing the isReadable method of > each, choose a MessageBodyReader provider that supports the desired Java type. > It says the entity providers should be sorted by media type firstly then(the media type is the same) on Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer application-provided over pre-packaged entity providers. So org.apache.cxf.jaxrs.provider.PrimitiveTextProvider should be selected as its media type MUST be text/plain and the application provider's media type is */*.(x/y>x/*>*/*) > So at this point the CTS expected response code is 200 instead of 406, the application provided provider should not be chosen. -- This message was sent by Atlassian JIRA (v6.3.4#6332)