commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <pbened...@apache.org>
Subject Re: Commons Lang 3: Validate
Date Mon, 23 Nov 2009 02:13:02 GMT
Stephen, that's why I thought a static flag would be a compromise, but
I don't think it's the best solution. Anyway, the changes I made
locally so far are this:

* notNull - throws NPE
* isTrue - throws IAE
* isValidIndex - throws IOOBE

Paul

On Sun, Nov 22, 2009 at 6:36 PM, Stephen Colebourne
<scolebourne@btopenworld.com> wrote:
> Henri Yandell wrote:
>>
>> On Thu, Nov 19, 2009 at 9:24 AM, Paul Benedict <pbenedict@apache.org>
>> wrote:
>>>
>>> On Thu, Nov 19, 2009 at 1:39 AM, Henri Yandell <flamefew@gmail.com>
>>> wrote:
>>>
>>>> Your argument being that the JDK and others do NPE when null? i.e. NPE
>>>> = IAE(null)?
>>>
>>> Yes. Some things to note:
>>> * The JDK does this as their pattern
>>> * JDK 7 definitely encodes this patter in their new Object.notNull()
>>> method.
>>> * Google Collections -- being a JDK wannabe addition -- does this
>>> * Josuha Bloch's "Effective Java" (two editions) has codified this
>>> expectation into the minds of developers.
>>
>> +1 to NPE.
>
> While I know this is the modern advice, there will be other places where any
> NPE is a bug, and thus Validate should throw IAE.
>
> There are no pretty solutions
> - two classes ValidateNPE and ValidateIAE?
> - some kind of static flag?
> - picking one, and offending the others?
>
> Stephen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Mime
View raw message