users@jersey.java.net

Re: [Jersey] null return values versus Content-Type header

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 May 2008 10:57:27 +0200

FSauer_at_dsthealthsolutions.com wrote:
>
>
> What is the recommended way to allow null return values (resulting in a
> 204 status) but still have the
> @ProduceMime annotation, without running into the following exception?
>

I am now wondering whether this exception is way to restrictive and the
returning of a null value should be equivalent to returning no content.

You can work around this by:

   return Response.noContent().build();

What should we do for this case:

   return Response.ok(null, "text/plain").build();

?

Should the rule be: if the entity is null and there is a Content-Type
header present then that header should be ignored and a warning should
be logged?

Paul.

> Thanks,
>
> Frank Sauer
>
>
> The "Content-Type" header is set to application/xml, but the response
> has no entity:
>
> javax.ws.rs.WebApplicationException
> at
> com.sun.ws.rest.impl.uri.rules.HttpMethodRule.verifyResponse(HttpMeth
> odRule.java:209)
> at
> com.sun.ws.rest.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.j
> ava:113)
> at
> com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPath
> Rule.java:88)
> at
> com.sun.ws.rest.impl.uri.rules.ResourceClassRule.accept(ResourceClass
> Rule.java:55)
> at
> com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPath
> Rule.java:88)
> at
> com.sun.ws.rest.impl.uri.rules.RootResourceClassesRule.accept(RootRes
> ourceClassesRule.java:49)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(Web
> ApplicationImpl.java:369)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.service(Servle
> tContainer.java:130)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> ------------------------------------------------------------------------
>
> * This e-mail and any attachments are intended only for the individual
> or company to which it is addressed and may contain information which is
> privileged, confidential and prohibited from disclosure or unauthorized
> use under applicable law. If you are not the intended recipient of this
> e-mail, you are hereby notified that any use, dissemination, or copying
> of this e-mail or the information contained in this e-mail is strictly
> prohibited by the sender. If you have received this transmission in
> error, please return the material received to the sender and delete all
> copies from your system. *
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109