FindBugs version: 0.9.994
Java version: 1.7
Following is code snippet, in this even if resource is closed in finally clause, FindBugs gives error to close it.
As resource is closed using try - resource statement which is introduced in Java 1.7.
try { readContent(); } catch (IOException e) { e.printStackTrace(); } private static void readContent() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new FileReader("D:\\Intellij\\EclipseFormast.xml")); System.out.println(br.readLine()); } finally { System.out.println("Gets Called"); if (br != null) br.close(); }
}
Findbugs 0.9.994??? OMG!
Current version is 3.0.0. Please update your installation and retest. We do not support older versions due the lack of resources.
Regards,
Andrey
Please check with newest FindBugs version. If you still notice a problem, report a new bug providing the whole Java source file which produces a false-positive. Thanks.
Android studio does not install plugin FindBugs 3.0.0.
While installing we get an error "Fail to load plugin descriptor from file findbugs-3.0.0.zip"
Last edit: vishal kharat 2015-02-18
Android studio is not based on Eclipse, it is based on IntelliJ IDEA.
We do not host or maintain FindBugs plugins for IDEA, please ask Google where the right project tracker for IDEA FindBugs plugin is - this one is wrong.
Probably 0.9.994 was the reference to IDEA plugin version, not the FindBugs version. See:
https://plugins.jetbrains.com/plugin/3847?pr=idea
It integrates with FindBugs 3.0.0.
Ok, I reopen it. But please provide the whole Java file where you observe this false-positive (simplify it as much as possible and remove all the external dependencies so we can compile it). Supplied code snippet is not enough for us to reproduce this problem.
By the way without reproducing I probably understand, what's the problem. You have System.out.println("Gets Called"); in your finally block before closing the stream. FindBugs thinks that this call may cause an exception and in this case your stream will not be closed. Having exception in System.out.println is possible (for example if you call System.setOut(null) somewhere else in your code or stack overflow occurs). You may either modify your code to use System.out after closing the stream or simply ignore this message if you're confident that System.out.println call will never throw an exception in your case.
I'm unable to reproduce this warning using the current version of FindBugs.