[jax-rs-spec users] [jsr339-experts] Re: Distance factor between wildcards

From: Sergey Beryozkin <>
Date: Wed, 22 May 2013 11:03:41 +0100

Hi Marek

I'm seeing few tests like this one:

We have 2 providers, lets say two MBRs, one with "*/*", another one with
"text/plain". The filter sets Content-Type to */*. MBR with "*/*" is
expected to be selected.

I've got temporarily confused re why MBR with text/plain has to be
selected, it definitely loses to MBR with */* on the distance factor.

This is why I asked. But I think I've sorted it out now.

If we have Content-Type: */* and one MBR with */* then if we depend on a
distance factor then it has to win over MBRs with more specific media
types because the distance here is 0.

However, here is a text from 4.2.3:

"When choosing an entity provider an implementation sorts the available
providers according to the media
types they declare support for. Sorting of media types follows the
general rule: x/y < x/* < */*, i.e. a
provider that explicitly lists a media types is sorted before a provider
that lists */*."

Which is what CXF does. So in the above example,

MBR (text/plain) is on top of the list, MBR (text/*) comes next (we also
assume both MBR have the same Java type supported).

And we have Content-Type: */*. We start from the top of the list.

And appears to me MBR (text/plain) is to be selected, simply because it
is the first one in the list, and text/plain intersects with */*.

Furthermore, if we apply those S functions which are used in the
selection of methods and response media types
S(*/*, */*) -> */*;d=0
S(*/*, text/plain) -> text/plain;d=2

text/plain;d=2 wins as text/plain is more specific

Do you agree ?

Thanks, Sergey

On 21/05/13 14:51, Marek Potociar wrote:
> I do not think that more generic providers would win over more specific ones. What use case do you have in mind? Let's try to step through the algorithm.
> Marek
> On May 20, 2013, at 11:30 PM, Sergey Beryozkin <> wrote:
>> Hi
>> what is a distance factor between
>> */* and */*.
>> Is it 0 ? This means it will let methods or providers declaring no Consumes or Produces win over methods/providers declaring more specific
>> media types values.
>> Sergey