[ 
https://issues.apache.org/jira/browse/MATH-856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13451052#comment-13451052
 ] 

Gilles commented on MATH-856:
-----------------------------

I don't agree with the above set of alternatives.

* Either we throw a standard NPE exception, which is not localizable since the 
localization happens at the call to "getLocalizedMessage" with the support of 
the CM-specific "ExceptionContext" (and since French messages are mandatory for 
some of Luc's applications, this option mandates the no-arg constructor),
* or we want to keep the possibility to check and report illegal usage of 
"null", with a localizable message; for this, "NullArgumentException" is 
appropriate (since it is a subclass of "MathIAE", it fulfills the requirement 
of your last paragraph).

Thus, we should not deprecate "NullArgumentException" after all (?), but we'd 
have to carefully set rules for when the check for "null" should or should not 
be done, lest contributors (new and old) will not get it right.

I'm still +1 for not checking for "null", whatsoever: It is a trivial bug. And 
having an explicit check (instead of just letting the JVM do it) will not make 
it easier for the user to answer the question: "Where did I forget to 
initialize that variable?"; he'll have to go to the stack trace anyways.

I don't think that anything is gained from checking for "null" and not throwing 
NPE (IAE is not NPE, MathIAE is not NPE, NullArgumentException is not NPE and 
soon won't be IAE anymore). From this will come only confusion.

                
> Deprecate "NullArgumentException"
> ---------------------------------
>
>                 Key: MATH-856
>                 URL: https://issues.apache.org/jira/browse/MATH-856
>             Project: Commons Math
>          Issue Type: Task
>    Affects Versions: 3.0
>            Reporter: Gilles
>            Priority: Trivial
>             Fix For: 3.1, 4.0
>
>
> [Discussions|http://markmail.org/message/cl2e6c4pqbluo63e] on the "dev" ML 
> concluded that "NullArgumentException" was more of a burden to maintain than 
> it brings benefits.
> It will be deprecated in 3.1 and removed in 4.0.
> Checks for "null" in CM code will either be maintained or be removed.
> Whenever checks for "null" are performed, the exception to be thrown is the 
> standard "NullPointerException" (instantiated with the no-arg constructor).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to