Wang Hailong created LANG-1743:
----------------------------------

             Summary: 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


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