Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this IntelliJ inspection warning a false positive?

I'm looking at ProducerPerformance.java from https://github.com/apache/kafka.

Looking at this part of the file:

        byte[] payload = null;
        Random random = new Random(0);
        if (recordSize != null) {
            payload = new byte[recordSize];
            for (int i = 0; i < payload.length; ++i)
                payload[i] = (byte) (random.nextInt(26) + 65);
        }

There is an inspection saying that "Condition i < payload.length is always false."

I don't see how it could always be false. recordSize is an Integer coming from a command-line parameter. Is there something I'm not seeing here?

like image 942
k314159 Avatar asked Oct 27 '22 13:10

k314159


1 Answers

This warning happened with IntelliJ IDEA 2020.*. The latest version, 2021.1, fixes this issue.

like image 172
k314159 Avatar answered Nov 09 '22 23:11

k314159