commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: [Math] About "NullArgumentException"
Date Mon, 10 Sep 2012 22:35:24 GMT
On Mon, Sep 10, 2012 at 01:31:12PM -0700, Phil Steitz wrote:
> On 9/10/12 11:47 AM, S├ębastien Brisard wrote:
> > Hi
> > What should I do there?
> > I'm trying to work on MATH-854. It turns out that FieldElement<T>.add
> > throws a NAE. Should I catch it below, and rethrow it with a more
> > detailed message (including the entry index)?
> IMO, yes.
> I would also check v itself and add to the javadoc contract that IAE
> is thrown if v is null.  This is not consistently done in [math],
> though, and rarely in the linear package, so I am OK just letting
> the NPE propagate if v is null.   It is a little awkward that v
> itself being null leads to NPE, but a component of it null leads to

Awkward? Of course it is; that's what I explained two posts ago.

If we want to allow for the possibility of checking for null (and I agree
that it could be useful to pinpoint the problem by passing the information
about which index contains an invalid null entry), then we should adopt the
second option which I presented in that preceding post:

  "NullArgumentException" inherits from "NullPointerException"

This really solves all issues (now that Luc has said that it is not a
problem if this one exception escapes the single-root hierarchy): It allows
to check for null in CM code and raise the same kind of exception that would
arise when no null check is performed. Both flexible and consistent.


> [...]

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

View raw message