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