If I have the following code in a servlet:
Properties p = new Properties();
p.load(getClass().getResourceAsStream("/test.properties"));
If I started the servlet through FindBugs, I would expect to receive an OS_OPEN_STREAM warning , but I will not. If I use a similar approach to open an arbitrary file in the file system (i.e. Not in the classpath), I get a Findbugs warning as expected:
Properties p = new Properties();
p.load(new FileInputStream(new File("c:/test.properties")));
In the first example, there is no warning, because Findbugs does not have a valid warning (i.e., should I close the stream in the finally block after loading into the Properties object), or is there a reason why I do not need to close the stream?
thank
Rich
source
share