On 8/31/07, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
>
>
>
> (ii) UriBuilder state after a call to .build(...)
>
> Should the state be maintained after a call to build or should the
> builder be reset back to blank state ?
Hmm, should it be idempotent on multiple invocations of build()? I like the
idea that one can make some small changes and reuse the builder...
Response.Builder.build resets
> the state to blank to avoid a deep-copy of the builder contents to
> prevent subsequent modifications from affecting the returned
> Response.
Instead I think it should just return an immutable response (private final
fields). I am not sure about entity references, if a user holds onto one and
mutates it that is a risk that should be documented clearly (better to avoid
deep copy as you say).
Since UriBuilder.build returns a URI we don't have that
> problem so we can either reset or maintain the current state.
>
> (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.
On the one hand it seems like treating the two the same could be
> convenient, on the other hand null is often used to indicate
> something different to "" so we might not be doing developers a favor
> by masking the difference.
I certainly think it is a hack to swallow nulls as acceptable jitter. Im not
even in favor of null as a concept in the language and hope Java will
eventually introduce enough of a facility to get rid of it altogether or at
least reduce its necessity to a lesser evil (a la "Nice"). That may be
somewhat controversial =)
Dhanji.