users@jsr311.java.net

Re: How to treat null values in ResponseBuilder

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 06 Apr 2009 11:29:20 -0400

On Apr 6, 2009, at 11:21 AM, Sergey Beryozkin wrote:
>
> I'm getting a bit confused by Response and ResponseBuilder java docs.
>
> For example, Response.created(URI location) says :
> java.lang.IllegalArgumentException - if location is null
>
> Now, Response.created() delegates to ResponseBuilder.location(URI
> location) which
> says :
>
> location - the location. ... If null any existing value for location
> will be removed.
>
> What should ResponseBuilder implementations do, for ex in
> location(URI location) method, when a null is passed ?
>
Implementations should conform to the Javadoc :-D.

The disparity here is due to the different semantics of the two
methods. Response.created is a high level method that is used to
jumpstart the building of a HTTP created response which should include
a location header. ResponseBuilder.location is the low level method
for setting the value of the location header and it needs to support
both setting and unsetting values for folks that know exactly what
they are doing.

HTH,
Marc.