Re: UriBuilder Questions

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 04 Sep 2007 15:38:53 -0400

On Aug 30, 2007, at 11:33 PM, Dhanji R. Prasanna wrote:
>> (iii) What to do about null parameter values
>> We touched on this earlier in the discussion about a URI builder but
>> I don't think think we came to any conclusion. Lots of the builder
>> methods take a String where a value of "" or null could be
>> meaningful. Should we treat the two values as equivalent or should
>> null generate a NullPointerException ? E.g. path("") would presumably
>> add an empty path segment, should path(null) do the same or should it
>> be an error ?
> It should be an error, null is not a valid object. Since we are
> trying to
> have fail-fast validation I think throwing an IAE on null (or any
> other
> invalid value) should be the way to go at the call point.
Works for me. For consistency I think that it should also be an error
if a no value is supplied for a URI template parameter. Currently the
build methods specify that any URI template parameters without a
value will be replaced by the empty string so that would be a change
rather than a clarification.


Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.