In general I agree, but in this case I think the check is warranted because it used to be "fine" (in 2.4) to pass null -- nothing bad would happen.
But as of the new TokenStream API, you'll suddenly hit an NPE, so I think we should throw an informed exception so it's clear to users what used to be accepted is in fact now explicitly disallowed. Mike On Fri, May 22, 2009 at 10:16 AM, Yonik Seeley <ysee...@gmail.com> wrote: > Why do stuff like this? Null params are almost never valid unless > documented... I dislike cluttering up code with validity checks, > slightly penalizing users who use the APIs correctly. I recognize > that I may be in the minority though. > > But in this specific instance, the caller will get an immediate NPE if > they pass a null anyway. > > -Yonik > http://www.lucidimagination.com > >> public AttributeSource(AttributeSource input) { >> + if (input == null) { >> + throw new IllegalArgumentException("input AttributeSource must not be >> null"); >> + } >> this.attributes = input.attributes; >> } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-dev-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org