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

Mousa Al Bateh commented on LANG-1743:
--------------------------------------

[~ggregory] 

Having a second look at this, why not use Optional instead in the next release? 
Isn't it more appropriate? I'm generally against returning null or passing 
nulls anywhere. Returning an empty optional seems better in my opinion and 
tells developer also that they should lookout for what could be returned.

> 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)

Reply via email to