commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: [Math] Usage of "NullPointerException"
Date Thu, 05 Aug 2010 22:38:52 GMT
> >> The added value that I see is that an IAE designating which argument
> >> that cannot be null is in fact null gives more specific information
> >> to the caller (or production support person examining logs) than
> >> just a propagated NPE.
> > 
> > Well, my initial post reported the inconsistency of throwing either NPE or
> > IAE as a result of checking for "null". If we take that NPE signifies a bug
> > in CM, then we can have the policy of throwing IAE when null is encountered
> > (and never explicitly throw NPE from CM).
> > 
> +1 - that is what I meant by my option 1) above.

This was your option 1:

>> 1) remove NPE wrappers, propagating uwrapped NPEs where the code
>> wraps and rethrows NPE today.

As I said, there are no wrappers around the NPE generated in CM. Either
"createNullPointerException" or "createIllegalArgumentException" is called
and they generate the corresponding exception (not wrapped within anything).

What I propose (as an alternative the "simple" policy) above is to create
a "NullArgumentException" that inherits from "MathIllegalArgumentException".
This exception will be thrown whenever a null check fails (i.e. "null is an
illegal argument"). To be consistent, we should never throw NPE from CM.
Is that what you meant to agree with?


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

View raw message