"Resource never closes" in try-with-resources when chaining methods

try(InputStream in = url.openStream(); Scanner scanner = new Scanner(in).useDelimiter("\\A")) {

} catch(IOException e) {
    e.printStackTrace();
}

Line

new scanner (in)

gives a warning:

Resource leak: <unassigned Closeable> value' is never closed

It is deleted if I delete useDelimiter(String).

useDelimiter(String)doesn't return a new instance (it returns this), so why am I getting this warning? This is mistake?

I am using Eclipse 4.4. My question does not apply to this , where the warning is due to a different situation.

+4
source share
2 answers

Yes, it looks like a leak check error. I would recommend reporting a bug. An initial Google search seems to not exist yet.

, , . , , useDelimiter .

0

IntelliJ . , useDelimiter() . , , IntelliJ / Eclipse:)

0

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


All Articles