SourceForge has been redesigned. Learn more.
Close

#1142 OBL_UNSATISFIED_OBLIGATION false positive

closed-wont-fix
5
2012-12-10
2012-12-08
No

Sent in via email t

the following case produces a false positive. As you can see, the stream is closed in the finally block oft he called function:

public abstract class TestdataReader {

public <T> T deSerialize(final File file) throws IntrospectionException, IOException, SAXException {
return (T) deSerialize(new FileInputStream(file)); // <== false positive here
}

public <T> T deSerialize(final InputStream inputStream) throws IntrospectionException, IOException, SAXException {
try {
return (T) beanReader.parse(inputStream);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}

Discussion

  • William Pugh

    William Pugh - 2012-12-10
    • status: open --> closed-wont-fix
     
  • William Pugh

    William Pugh - 2012-12-10

    FIndBugs doesn't do the interprocedural analysis needed to avoid this issue.

    If you annotate the parameter of deSerialize(InputStream) with @WillClose, the issue won't be reported.

     

Log in to post a comment.