[
https://issues.apache.org/jira/browse/LANG-1743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17898005#comment-17898005
]
Mousa Al Bateh commented on LANG-1743:
--------------------------------------
I wasn't clear in my previous comment, sorry; let me explain what I meant.
I meant that I changed my mind about the change that I made since to your
point, this would break existing applications. However, what I did mean is, why
don't we gradually deprecate this and add new similar methods that do not
return or pass null but existing apps can still use the would be deprecated
methods.
So the new methods can serve similar functionalities (with different method
names) but they utilize the Optional class. This way, future apps will use
Optional and existing apps do have a choice to use Optional.
I found after my initial PR that the issue mentioned in this Jira story was
already addressed for that concrete edge case; but I'm opening the pandora box
on the matter of using nulls.
To be honest, whether nulls are used or not, I don't mind it. I just tend to
find avoiding nulls in general a good idea but understand that we can't avoid
null always.
> 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)