Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/NewCollectionAliasing.java
Tagir Valeev f8bd662378 [java-inspections] Mark standard collection constructors as pure
IDEA-299423 NPE false positive in static analysis involving collection emptiness check

GitOrigin-RevId: c15b5117e0c58ebbe5617d221db66ecf969f5204
2022-08-08 14:16:01 +00:00

20 lines
744 B
Java

// IDEA-299423
import java.util.*;
class Test {
private static void exampleThree() {
final Queue<String> queue1 = new ArrayDeque<>(List.of("foo1", "bar1"));
final Queue<String> queue2 = new ArrayDeque<>(List.of("foo2", "bar2"));
final Queue<String> queue3 = new ArrayDeque<>(List.of("foo3", "bar3"));
if(!queue1.isEmpty() && !queue2.isEmpty() && !queue3.isEmpty()) {
final String poll1 = queue1.poll();
final String poll2 = queue2.poll();
final String poll3 = queue3.poll();
// NPE warning for poll2.getBytes() and poll3.getBytes() because poll2 and poll3 might be null
if (poll1.getBytes().length == poll2.getBytes().length || poll3.getBytes().length != 0) {
// ...
}
}
}
}