Java code inspections not working

Answered

I wrote this class, turned on Resource Management -> AutoCloseable used without 'try'-with-resources with a default Warning severity, and I was expecting a warning that I am not getting.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;

public class InspectionTest {

public void leakMemory() throws IOException {
URLConnection conn
= new URL("http://norvig.com/big.txt").openConnection();
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
}

public static void main(String[] args) throws IOException {
System.out.println("Hello world");
new InspectionTest().leakMemory();
}

}
0
2 comments
Avatar
Permanently deleted user

The question is that I am using a auto-closeable resource, that I am not explicitly closing nor using 'try-with-resources' statement. So I was expecting a warning from Intellij warning me about a possible memory leak and suggesting to refactor the code, which I am not seeing.

I got this working with Intellij CE but first time using Ultimate version is not working, and I don't know why.

0

Please sign in to leave a comment.