The new Stream#toList() method in JDK16 is not recognized as terminal operator by SonarLint and triggers this error:
Intermediate Stream methods should not be left unused
Bug
Major
java:S3958
Versions used:
- InteliJ: IntelliJ IDEA 2021.1 (Ultimate Edition) Build #IU-211.6693.111
- SonarLint plugin for InteliJ: 4.14.2.28348
- JDK 16 (AdoptOpenJDK 16.0.0.j9)
Minimal code sample to reproduce:
private List<String> test() {
return Stream
.of("test")
.map(String::toUpperCase) //removing this line suppresses the error
.toList();
}