Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DA5C2200BD9 for ; Fri, 9 Dec 2016 19:48:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D92EB160B1D; Fri, 9 Dec 2016 18:48:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 04E39160AFD for ; Fri, 9 Dec 2016 19:48:07 +0100 (CET) Received: (qmail 41762 invoked by uid 500); 9 Dec 2016 18:48:02 -0000 Mailing-List: contact dev-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 dev@cxf.apache.org Received: (qmail 41748 invoked by uid 99); 9 Dec 2016 18:48:01 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Dec 2016 18:48:01 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5AA4C1A9DC2 for ; Fri, 9 Dec 2016 18:48:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.de Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id xBiqkl8nPcsX for ; Fri, 9 Dec 2016 18:47:58 +0000 (UTC) Received: from nm12-vm4.bullet.mail.ne1.yahoo.com (nm12-vm4.bullet.mail.ne1.yahoo.com [98.138.91.172]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 941A45F58F for ; Fri, 9 Dec 2016 18:47:58 +0000 (UTC) Received: from [98.138.100.115] by nm12.bullet.mail.ne1.yahoo.com with NNFMP; 09 Dec 2016 18:47:49 -0000 Received: from [98.138.104.114] by tm106.bullet.mail.ne1.yahoo.com with NNFMP; 09 Dec 2016 18:47:49 -0000 Received: from [127.0.0.1] by smtp223.mail.ne1.yahoo.com with NNFMP; 09 Dec 2016 18:47:49 -0000 X-Yahoo-Newman-Id: 590866.21929.bm@smtp223.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 2YHmd.cVM1nsiRNP309LdgnnsN4P.lu.iSr3n3zJ4z1u.4K u.mHP.MOaZaM9jCEiKRyIGjRtjYVMczvlC5ZVLWnQqm6fKSQfgBr0ci_6UOo iV3HV_x2yDe0y39TZ.ij2gnP66I.lKjOAoVCRuiDVh85z29aFXBgwdsSCWmx LLh2.JhMK3Vo2XTUGXKoAFsxMNm.KKmMLP2rdCHWEXm_5bDPohFRZggDoQVD C.rRSe6ndHzKie5mXvMUChG8uv.ou7cIXFBrvDEliyZkKk71qatbcWYV5MlN QIK1LX_4bAgQs7dJ2.Ctx5fcNKdZJUiC5QnUUcN.iWreDO5RYe5xVrC2EJdo v7AIzl0vpAyJZU1ONqt9XUFyA.N9ec6HzKfWMQBSwbBeKUCQNyIMmtrFI8i_ 8TltLMtM2EMmvCgpof88rAWkXtw_gJvArfPznCjUTA7j81bz2SZDW8Dl5Q32 3CDZTBIShbz27mkN8710DV31FP416xhj_5vi.1AkZ1HAC9lqXbEha7r26gEB DZ1a1D_J8M8H8k9uRAucARLjz7uYBo1sYOKkS4hm9CWy0QWirFdkj1U7f.pP MvA-- X-Yahoo-SMTP: 81dhI.iswBBq7boyzRoOX6xuRIe8 From: Mark Struberg Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: MediaType matching question Date: Fri, 9 Dec 2016 19:47:46 +0100 References: <32DE5B4C-4388-4371-9E28-34D4F3E493DC@yahoo.de> <456020132.1100977.1481300226679@mail.yahoo.com> <2aa27848-59af-addf-cbcb-90f14a9f8833@gmail.com> <2137963384.1126751.1481303511562@mail.yahoo.com> To: dev@cxf.apache.org In-Reply-To: Message-Id: <1C364EC7-E0B0-4AF9-9EF5-427B126EB445@yahoo.de> X-Mailer: Apple Mail (2.3251) archived-at: Fri, 09 Dec 2016 18:48:09 -0000 Yes it does, but it doesn't seem to be a CXF bug. The bug is in the RI = API (and in geronimo we ported the logic 1:1). I'm also not sure if this is a 'bug' in the API or in the spec.=20 =46rom a user pov it seems counter intuitive at least. LieGrue, strub > Am 09.12.2016 um 18:22 schrieb Sergey Beryozkin = : >=20 > Hmm, > are you saying CXF will match "*/*+json" against = application/octet-stream ? I have to sign off right now, but I honestly = doubt it, I'll check later on. >=20 >=20 > Thanks, Sergey >=20 >=20 >=20 > On 09/12/16 17:11, Mark Struberg wrote: >>> Do you expect a "*/*+json" match the application/octet-stream ? >>=20 >>=20 >> No, I did not expect that. But that's exactly how the code of = MediaType#isCompatible behaves currently :( >>=20 >>=20 >>=20 >> LieGrue, >> strub >>=20 >>=20 >>=20 >>=20 >>> On Friday, 9 December 2016, 17:24, Sergey Beryozkin = wrote: >>>> Hi Mark, welcome, >>>=20 >>> Do you expect a "*/*+json" match the application/octet-stream ? >>> And how is the method parameter accepting a multipart payload is = typed, >>> as InputStream ? >>>=20 >>> As a side note with WebClient you can use a more dedicated = Attachment >>> code but on the server side, if you need to stay 100% compliant, = then >>> yes, you;d need to read from InputStream and parse the payload = manually >>> - CXF MultipartProvider will not touch it unless it is annotated = with a >>> CXF specific annotation >>>=20 >>> Cheers, Sergey >>>=20 >>>=20 >>> On 09/12/16 16:17, Mark Struberg wrote: >>>> While debugging through this didn't get used as far as I remember. >>>>=20 >>>> Maybe MultipartProvider uses an alternative path to detect the = handlers? >>>>=20 >>>> LieGrue, >>>> strub >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>> On Friday, 9 December 2016, 17:15, Romain Manni-Bucau >>> wrote: >>>>>> Hey Mark, >>>>>=20 >>>>> have a look >>>>> to >>> = org.apache.cxf.jaxrs.provider.ProviderFactory.MessageBodyWriterComparator >>>>> (and the reader companion) maybe. Got aligned in cxf "jaxrs >>> 2" for >>>>> spec >>>>> alignment >>>>>=20 >>>>>=20 >>>>> Romain Manni-Bucau >>>>> @rmannibucau | Blog >>>>> | Old Blog >>>>> | Github >>>>> | >>>>> LinkedIn | JavaEE >>> Factory >>>>> >>>>>=20 >>>>>=20 >>>>> 2016-12-09 17:10 GMT+01:00 Mark Struberg >>> : >>>>>=20 >>>>>> good evening! >>>>>>=20 >>>>>> My first post to CXF, so I excuse if I ask something obvious ;) >>>>>>=20 >>>>>> We have the following code over in Apache OpenWebBeans / >>> Meecrowave: >>>>>>=20 >>>>>> @Produces({ >>>>>> "application/json", "*/json", >>>>>> "*/*+json", "*/x-json", >>>>>> "*/javascript", "*/x-javascript" >>>>>> }) >>>>>> @Consumes({ >>>>>> "application/json", "*/json", >>>>>> "*/*+json", "*/x-json", >>>>>> "*/javascript", "*/x-javascript" >>>>>> }) >>>>>> public static class ConfiguredJsonbJaxrsProvider extends >>>>>> JsonbJaxrsProvider { >>>>>>=20 >>>>>> I tried to use the CXF WebClient to send a multipart form with a >>> file >>>>>> attachment. MediaType is application/octet-stream. >>>>>> Sadly I always triggered our Johnzon JSONB provider >>> (johnzon.apache.org). >>>>>>=20 >>>>>> The reason is that */json seems to match ANY other MediaType, >>> regardless >>>>>> of the subtype. Is this intended? >>>>>> The code I found during debugging is the following in >>> geronimo-jaxrs_2.0 >>>>>> MediaType: >>>>>>=20 >>>>>> public boolean isCompatible(MediaType other) { >>>>>> return other !=3D null && >>> (type.equals(MEDIA_TYPE_WILDCARD) || >>>>>> other.type.equals(MEDIA_TYPE_WILDCARD) || >>>>>> (type.equalsIgnoreCase(other.type) && >>>>> (subtype.equals(MEDIA_TYPE_WILDCARD) >>>>>> || other.subtype.equals(MEDIA_TYPE_WILDCARD))) || >>>>>> (type.equalsIgnoreCase(other.type) && >>>>>> this.subtype.equalsIgnoreCase(other.subtype))); >>>>>> } >>>>>>=20 >>>>>>=20 >>>>>> I'm geronimo PMC myself so I can even fix it. But would need >>> some >>>>> feedback >>>>>> how it should behave. >>>>>> https://svn.apache.org/repos/asf/geronimo/specs/trunk/ >>>>>> geronimo-jaxrs_2.0_spec/ >>>>>>=20 >>>>>> I did a quick look at the RI and now I'm even more confused: >>>>>>=20 >>>>>> public boolean isCompatible(MediaType other) { >>>>>> return other !=3D null && // return false if other >>> is null, >>>>> else >>>>>> (type.equals(MEDIA_TYPE_WILDCARD) || >>>>>> other.type.equals(MEDIA_TYPE_WILDCARD) || // both are wildcard >>> types, or >>>>>> (type.equalsIgnoreCase(other.type) >>> && >>>>>> (subtype.equals(MEDIA_TYPE_WILDCARD) >>>>>> || >>>>> other.subtype.equals(MEDIA_TYPE_WILDCARD))) >>>>>> || // same types, wildcard sub-types, or >>>>>> (type.equalsIgnoreCase(other.type) >>> && >>>>>> this.subtype.equalsIgnoreCase(other.subtype))); // same types >>> & >>>>> sub-types >>>>>> } >>>>>>=20 >>>>>> It says "both are wildcard types" but the code is >>> actually ONE of >>>>> them is >>>>>> a wildcard type, isn't? >>>>>> (type.equals(MEDIA_TYPE_WILDCARD) || >>>>> other.type.equals(MEDIA_TYPE_WILDCARD) >>>>>> || // both are wildcard types, or >>>>>>=20 >>>>>>=20 >>>>>> Any hints are highly welcome, my head is already hurting... >>>>>>=20 >>>>>> What are the actual rules for matching MediaTypes? What does the >>> spec >>>>>> define? >>>>>>=20 >>>>>> txs and LieGrue, >>>>>> strub >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>=20 >>>=20 >>>=20 >>> -- >>>=20 >=20 >=20 > --=20 > Sergey Beryozkin >=20 > Talend Community Coders > http://coders.talend.com/