Apache collections lang3 ArrayUtils.isNotEmpty : null pointer exception

SonarLint 4.16.0.31

I got (14,52) A “NullPOinterException” could be thrown; “params” is nullable here. In my opinion ArrayUtils.isNotEmpty checks for null, so the sonar should not report this warning. Miss i something, or is it really false positive.

Many thanks, Ondra

Here is the problematic code:

import org.apache.commons.lang3.ArrayUtils;

class TestClass {

    private static void method(int params[]) {

        if (params != null) {
            // do something
        }

        if (ArrayUtils.isNotEmpty(params) && params[params.length - 1] == 1) {
            // do something
        }
    }
}

Hi Ondřej,
You didn’t miss something, the java analyzer does not support ArrayUtils, so we should only blame it.
I created SONARJAVA-3891 to add the support of ArrayUtils.
Thanks for your feedback,
Alban

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.