FindBugs: "may fail to close stream" - is this valid in case of InputStream?
Posted
by thSoft
on Stack Overflow
See other posts from Stack Overflow
or by thSoft
Published on 2010-04-03T09:44:49Z
Indexed on
2010/04/03
9:53 UTC
Read the original article
Hit count: 447
In my Java code, I start a new process, then obtain its input stream to read it:
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
FindBugs reports an error here:
may fail to close stream
Pattern id: OS_OPEN_STREAM, type: OS, category: BAD_PRACTICE
Must I close the InputStream of another process? And what's more, according to its Javadoc, InputStream#close() does nothing. So is this a false positive, or should I really close the input stream of the process when I'm done?
© Stack Overflow or respective owner