Skip to content
Advertisement

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?

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement