In many places, the method IOUtils.closeQuietly() is used to unconditionally close objects that implement the interface Closable (FileInputStreams, FileOutputStreams, ...).
Although the use of this method in finally blocks is correct and fits its purpose, Closable's should be additionally closed using the method close() within the corresponding try blocks. Otherwise, exceptions that could occur when closing a Closable will simply be ignored - possibly leading to unnoticed data corruption/loss.
Although failing on close() maybe unlikely and I do not provide the requested steps of reproduction here, its possible consequences should be absolutely avoided.
References:
See the code examples of method closeQuietly() on http://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html#closeQuietly(java.io.Closeable)
I noticed that as well and will try to fix that if I have some time left. If anyone else wants to take this ticket from me, go ahead.
As we are using Java 7 starting form 1.6 we could also think about encouraging the use of try-with-resource statements instead (http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html)
Or do something like:
try {
/* Do something with stream */
in.close();
} catch (IOException e) {
/* error handling: log error, return error response */
} finally {
IOUtils.closeQuietly(in);
}
This has already been fixed at several places but we should go through the code one explicitly searching for this
Fixed on several places, keep an eye on this for new PRs