[
https://issues.apache.org/jira/browse/LANG-1743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17867335#comment-17867335
]
Gary D. Gregory commented on LANG-1743:
---------------------------------------
We could use Objects.requireNonNull but you'd still get an NPE.
It seems to me that {{NullPointerException}} is the most precise exception and
tells a developer _exactly_ where to look. Throwing IAE is more general and
therefore less useful.
What do others think?
> when ArrayUtils.removeAll meeting 'null' array
> ----------------------------------------------
>
> Key: LANG-1743
> URL: https://issues.apache.org/jira/browse/LANG-1743
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.14.0
> Environment: jdk18
> Reporter: Wang Hailong
> Priority: Major
>
> it just throw java.lang.NullPointerException: Cannot invoke
> "Object.getClass()" because "array" is null, hope a more propel way to handle
> this situation, for example just return null, or raise the illeagleargument
> exception (the array must not be null)
> the test code is :
> {color:#bbb529}@Test
> {color}{color:#cc7832}public void
> {color}{color:#ffc66d}testRemoveAll_NullArray{color}() {
> {color:#808080}// Preparation of the test case
> {color}{color:#808080} {color}{color:#cc7832}char{color}[] array =
> {color:#cc7832}null;
> {color}{color:#cc7832}
> {color}{color:#cc7832} {color}{color:#808080}// Invocation of the API
> {color}{color:#808080} {color}{color:#cc7832}char{color}[] result =
> ArrayUtils.removeAll(array){color:#cc7832};
> {color}{color:#cc7832}
> {color}{color:#cc7832} {color}{color:#808080}// Final assertion
> {color}{color:#808080} {color}assertArrayEquals({color:#6a8759}"Removing
> elements from a null array should return null"{color}{color:#cc7832}, null,
> {color}result){color:#cc7832};
> {color}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)