Resources should be closed not warns on new FileInputStream

The following java code should create a sonar warning of “Resources should be closed (squid:S2095)”
Because FileInputStream (resource) in created and not closed in code

public static String getMD5Checksum(String filePath) throws Exception {
    File file = new File(filePath);
    FileInputStream fis = new FileInputStream(file);
    return DigestUtils.md5Hex(fis);
}

Notice that if we add fis.read(); it warns OK

Hello. Can anybody answer? I am very interested by the subject also… Thank you…

Hello. Can anybody answer? I

Hi,

Thank for noticing that, I’ve created a ticket.