Categories
eclipse java java-stream

Why doesn’t Eclipse show leak warning for streams?

In Eclipse Neon, if I write this Java code:

Stream<Object> stream = Stream.builder().build();

I get no leak warnings, but if I implement Stream, such as

public class MyStream<T> implements Stream<T> {
// implementation
}

and I write similar code

Stream<Object> stream = new MyStream<>();

I get a Resource leak: 'stream' is never closed warning. This happens only in Eclipse, while compiling with javac does not issue any warning.

Note I’m not looking for an answer on how to close the stream and such, but for an answer which explains the reason of this different behavior for the same interface.