[S3958] Stream#toList (JDK 16) is not recognized as terminal operator

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



Versions used:

  • InteliJ: IntelliJ IDEA 2021.1 (Ultimate Edition) Build #IU-211.6693.111
  • SonarLint plugin for InteliJ:
  • JDK 16 (AdoptOpenJDK 16.0.0.j9)

Minimal code sample to reproduce:

  private List<String> test() {
    return Stream
        .map(String::toUpperCase) //removing this line suppresses the error 

Hey @MartinBG

This should be addressed when we bring full support of Java 16 to our products: you can track SONARJAVA-3746 for this specific case and MMF-2317 for the broader effort.

This all has a dependency on the release of a new version of the ECJ (SONARJAVA-3738) so probably early summertime.


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