commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [lang] StringUtils.containsOnly
Date Fri, 27 Sep 2002 09:52:45 GMT
>  from:    Steve Downey <>
> Also, this is a case of 'fixing' the standard Java library. 
> String.indexOf(String str) will throw a NPE if str is null. [That's where 
> indexOfAny will throw] It also can't be called on a null string. 

IMO StringUtils is a different proposition to a String instance, simply because it's not an
instance. NPE is an error when using an instance that is null, IAE is an error that gives
you much more semantic information.

> On Thursday 26 September 2002 08:14 pm, Steven Caswell wrote:
> > My opinion, in this order:
> >  1 on silent handling of null
> >  1 on throwing IAE if silent handling doesn't make sense
> > -1 on throwing NPE

I agree (plus)1 on this summary.

Henri, this has come up before. If the [collections] project influences the debate then NPEs
are favoured. This is because the collections spec forces this.

My solution to this issue in my own work is a Validate static class, similar to JUnits assert
that will check parameters and throw an exception.

The question at hand is whether we should delay or not. I don't know without looking in detail
at each method and working it through as to what the effects are. 

After some thought, I favour release now. We've waited long enough already. Changing exception
handling for these cases does not seem terribly significant to me, and if necessary we have
to go to 2.0 not 1.1.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message