When I ananyze some code using sonarlint in eclipse which close the FileReader in the finally block, the sonarlint prompt me that "Close this 'FileReader'" which is generated by the rule "Resources should be closed". Is this a bug from SonarLint?. Is this a bug from SonarLint?
I can't use try-with-resources features, because our project using JDK 1.6
The code is like below:
FileReader fr = null;
try {
fr = new FileReader(pidFile);
oldPid = new BufferedReader(fr).readLine();
}
catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
finally {
try {
if (fr != null) {
fr.close();
}
}
catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
}