I am using Java 8 streams in place of many old style for loops to iterate through a bunch of results and produce summary statistics. For example:
int message
It isn't closed, because AutoCloseable
interface works only inside try-with-resources
. But this close operation is totally unnecessary for IntStream
as it said in AutoCloseable
interface javadoc
:
However, when using facilities such as java.util.stream.Stream that support both I/O-based and non-I/O-based forms, try-with-resources blocks are in general unnecessary when using non-I/O-based forms.
So yes S2095 is a false positive for IntStream. That will be hopefully fixed by SONARJAVA-1478