lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: svn commit: r777525 - /lucene/java/trunk/src/java/org/apache/lucene/util/AttributeSource.java
Date Fri, 22 May 2009 15:13:51 GMT
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 <yseeley@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-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message