Do not ignore exceptions when closing Closeable's


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.

See the code examples of method closeQuietly() on


Lars Kiesow
October 9, 2014, 12:12 AM

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.

Basil Brunner
November 5, 2014, 3:36 AM

As we are using Java 7 starting form 1.6 we could also think about encouraging the use of try-with-resource statements instead (

Lars Kiesow
November 14, 2014, 2:53 AM

Or do something like:

try {
/* Do something with stream */
} catch (IOException e) {
/* error handling: log error, return error response */
} finally {

Lars Kiesow
June 19, 2015, 4:29 AM

This has already been fixed at several places but we should go through the code one explicitly searching for this

Sven Stauber
April 6, 2016, 10:27 PM

Fixed on several places, keep an eye on this for new PRs

Fixed and reviewed


Sven Stauber


Sven Stauber

Tags (folksonomy)



Fix versions

Affects versions