When a method takes a stream or resource as input and close it in its content using directly .close() or another @WillClose annotated method on the same stream, FindBugs should report that it should also be annotated with @WillClose.
With that, we can hope to reduce the amount of false positive on stream leaks.
We do look at method names, and we generally treat methods named close as being annotated with @WillClose. See attached sample.
A lot of people don't want to add @WillClose annotations, because that adds a JSR-305 dependency to their project.
Do you have an example of code where a call to a close(...) method isn't being properly handled?
I'm using FindBugs 2.2.0 in Eclipse. and I get the report with a
InputStream stream = null;
try {
stream = new FileInputStream(...)
} catch (Exception ex) {
throw new WrapException(ex);
} finally {
IOUtil.close(stream); // IOUtil comes from codehaus plexus
}
Should I try a newer FindBugs version?
I can't reproduce the warning you are seeing, either with 2.0.2 or HEAD. See attached. Can you send me a compete, compilable source file, that shows the problem, along with a class file?