-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Labels
Description
Environment:
- VS Code Version:1.54.3
- Extension Version:v0.13.0
- JDK Type & Version:15.0.1
- OS Type & Version: Windows 10 x64 20H2
Step to Reproduce:
Write Java codes that contains for sentences between a Scanner declaration and scanner.close().For example:
import java.util.Scanner;
public class Main{
public static void main(String args[]) {
long max = 0;
long odd = 0;
long even = 0;
long i = 0;
Scanner reader = new Scanner(System.in);
max = reader.nextLong();
for (i = 3; i <= max; i += 3) {
if ((i & 1) == 1) {
odd += 1;
} else {
even += 1;
}
}
System.out.println(odd + "," + even);
reader.close();
}
}
there would be yellow waves under "reader" in declaration:
It said that reader wasn't closed properly, but when I add a line reader.nextLong();
, exceptions raised said reader was closed. So reader actually was closed properly, but the extension marked wrong.
Expected Behavior:
No warnings when I write reachable close() sentences.
Actual Behavior:
A warning appeared said "Resource leak".
Related Issues: