commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [Math - 403] Never propagate a "NullPointerException" resulting from bad usage of the API
Date Wed, 02 Mar 2011 10:33:46 GMT
> > [...]
> 
> I'm in favor of just letting the JVM throw NPE.  Since there is no
> message in this case, there is nothing to localize.  Using a class
> to check arguments is too much work, since the (localized) message
> "Something was null" is less than helpful.  And assert will be
> turned off in any reasonably configured production server so makes
> the code less readable and adds very little value.  If the null
> happens because of code in CM (as opposed to user error), then we'll
> get a Jira issue, fix it, and add a unit test.  If it is user error,
> then the stack trace of the NPE will tell the developer what was
> wrong in at least 95% of the cases.

That was my first line of arguments, a long time ago. But there was no
agreement mainly because of the will to retain the possibility of localizing
the message, even for NPE (i.e. one should be able to supply a "Localizable"
argument to the constructor of "NullArgumentException"). A second
counter-argument was that in a certain use-case, no stack trace is
available.


Best,
Gilles

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


Mime
View raw message