Why doesn't Eclipse detect leakage for threads?

In Eclipse Neon, if I write this Java code:

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

I have no leak warnings, but if I implement Stream, for example

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

and I write similar code

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

I get a warning Resource leak: 'stream' is never closed. This only happens in Eclipse, and compiling with javacno warnings.

Note. I'm not looking for an answer on how to close a thread, etc., but for an answer that explains the reason for this different behavior for the same interface.

+6
source share
2 answers

In the first case, you are not creating an instance of the resource. In the second case, you are.

The eclipse documentation reads as follows :

/
, , , . [...]
 - , , ; .

+3

Eclipse , , . Java, . . .

+4

Source: https://habr.com/ru/post/1015915/


All Articles