users@jsr311.java.net

Re: How to treat null values in ResponseBuilder

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 29 Apr 2009 12:04:20 -0400

This is a bug in 1.0 that was fixed in 1.1. The static fromPath method
now calls path instead of replacePath.

Marc.

On Apr 29, 2009, at 7:46 AM, Sergey Beryozkin wrote:

> Hi
>
> I still don't understand. Example :
> /**
>
>
>
> * @throws IllegalArgumentException if path is null
>
> */
>
> public static UriBuilder fromPath(String path) throws
> IllegalArgumentException {
>
> UriBuilder b = newInstance();
>
> b.replacePath(path);
>
> return b;
>
> }
>
> *
>
> * A null value will unset the path component of the URI.
>
> */
>
> public abstract UriBuilder replacePath(String path);
>
>
> There's no way in UriBuilder(Impl).replacePath(String path) to
> figure out if the call originated from
> UriBuilder.fromPath() or not.
>
> I believe UriBuilder.fromPath(String path) implementation (as well
> as created(), etc) is incomplete in that it does not throw
> IllegalArgumentException.
>
> Do you agree ?
>
> thanks, Sergey
>
>
>> 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.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>