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.
Thanks, Sergey
On 09/12/16 17:11, Mark Struberg wrote:
Do you expect a "*/*+json" match the application/octet-stream ?
No, I did not expect that. But that's exactly how the code of
MediaType#isCompatible behaves currently :(
LieGrue,
strub
On Friday, 9 December 2016, 17:24, Sergey Beryozkin <[email protected]>
wrote:
Hi Mark, welcome,
Do you expect a "*/*+json" match the application/octet-stream ?
And how is the method parameter accepting a multipart payload is typed,
as InputStream ?
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
Cheers, Sergey
On 09/12/16 16:17, Mark Struberg wrote:
While debugging through this didn't get used as far as I remember.
Maybe MultipartProvider uses an alternative path to detect the handlers?
LieGrue,
strub
On Friday, 9 December 2016, 17:15, Romain Manni-Bucau
<[email protected]> wrote:
Hey Mark,
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
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github
<https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE
Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2016-12-09 17:10 GMT+01:00 Mark Struberg
<[email protected]>:
good evening!
My first post to CXF, so I excuse if I ask something obvious ;)
We have the following code over in Apache OpenWebBeans /
Meecrowave:
@Produces({
"application/json", "*/json",
"*/*+json", "*/x-json",
"*/javascript", "*/x-javascript"
})
@Consumes({
"application/json", "*/json",
"*/*+json", "*/x-json",
"*/javascript", "*/x-javascript"
})
public static class ConfiguredJsonbJaxrsProvider<T> extends
JsonbJaxrsProvider<T> {
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).
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:
public boolean isCompatible(MediaType other) {
return other != 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)));
}
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/
I did a quick look at the RI and now I'm even more confused:
public boolean isCompatible(MediaType other) {
return other != 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
}
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
Any hints are highly welcome, my head is already hurting...
What are the actual rules for matching MediaTypes? What does the
spec
define?
txs and LieGrue,
strub
--
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/