为什么这段代码不会触发Sonar的“密切资源”违规(鱿鱼:S2095)

时间:2017-03-02 13:05:49

标签: java sonarqube sonarlint

我刚发现这段代码,并且希望Sonar Lint报告“资源应该关闭”squid:S2095问题。)

try {
        Properties props = new Properties();
        FileInputStream fis = new FileInputStream("myfile.properties");
        props.load(fis);
        fis.close();
        maxThreadPool = Integer.parseInt(props.getProperty("maxpoolsize", "20"));
    } catch (Exception e) {
        log.error("unable to property out of properties file", e);
        maxThreadPool = 20;
    }

我可以看到Sonar Lint在每次修改后扫描文件(我试图添加其他问题并找到它们)。此外,该问题在我们的Sonar服务器上的所选配置文件中处于活动状态,因为它在代码库的其他部分中发现资源问题。

我们在IntelliJ IDEA Ultimate 2016.3.4中使用Sonar 5.6.4和Sonar Lint 2.7.1.1640。

有人可以帮忙吗?

非常感谢!

0 个答案:

没有答案