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

J. Nathaniel Sloan commented on LANG-753:
-----------------------------------------

+1 for Oliver here.  By making this change, you've abandoned me at version 2.6. 
 The first test case I write for most methods is simply that it behaves 
rationally when presented with null input, especially where null is disallowed 
by the API.  Therefore, I have an entire suite of tests written to look for 
IllegalArgumentException.

Naturally, I could change the tests, but why would I do so?  Unless I'm willing 
to rewrite them all to check the message text, I can't differentiate between a 
NullPointerException thrown by the Validate method and one generated by making 
a method call on the null reference.

Version 2.6 performs two tasks: provides a readable message, which is good for 
log files and defect analysis, and changes the exception type from what you 
would otherwise get, which is good for automated testing.  Version 3.x does 
only the former.

Finally, +1 again for the idea that just because Oracle does something doesn't 
make it a best practice.  It was wrong when they wrote it into the spec for 
Comparator, and it's wrong now, for exactly the reasons in Oliver's first 
comment.  NullPointerException should be reserved exclusively for making method 
calls using null references.  If I wanted a NullPointerException, I'd just omit 
the call to Validate and let the code continue.

I hope you'll reconsider, and thanks for listening.
                
> Validate.notNull() should throw IllegalArgumentException but throws 
> NullPointerException
> ----------------------------------------------------------------------------------------
>
>                 Key: LANG-753
>                 URL: https://issues.apache.org/jira/browse/LANG-753
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.0, 3.0.1, 3.1
>            Reporter: Oliver Siegmar
>
> Validate.notNull() throws an IllegalArgumentException in commons-lang 2.6, 
> but in 3.0.1 it throws a NullPointerException. I can't find any note about 
> this in the release notes. I think this is a regression, because it could 
> break others code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to