users@jersey.java.net

Re: [Jersey] A MessageBodyWriter that produces “text/*” will return a response code 500 for a request for “text/*”

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 16 Apr 2010 15:41:45 +0200

On Apr 16, 2010, at 3:05 PM, Alex Treppass wrote:

> When the ContainerResponse generates the appropriate mime type
> checks to see whether the mime type is null or contains wildcards.
> If true then it overwrites the specified mime type with application/
> octet-stream. The ContainerResponse then attempts to find a
> MessageBodywriter for application/octet-stream and throws a 500
> because it is unable to find one.
>


In the absence of any acceptable concrete media type declared by the
client in the Accept header the application must provide a concrete
text/* compatible media type either using @Produces (on the resource
or writer) or by declaring the media type in a built Response.

Given that a message body writer is found to support the wild card
media type but yet a compatible concrete media type does exist to
define the Content-Type then it does indicate a server-side error and
not a client side error.

I agree though attempting to fall back on to application/octet-stream
is perhaps not the right thing to do. Need to think more about why i
did that and what regressions that might cause if we change it.

Paul.