gradle/gradle — pull request #170 by fge (2013-06-26 01:28:15+00:00)
Title: Add a class to properly handle multiple I/O resource closing and flushing

I initially forked to try and cure the bug with the jar plugin adding all files twice when the classesDir and resourcesDir were equal, but then I stumbled upon that.

In JarUtil, in the event of an I/O failure, the underlying File{Input,Output}Stream would in fact never be closed, since the only I/O resources closed were the ZipInputStream and BufferedOutputStream. Fix by creating a CloserFlusher utility class inspired by Guava's Closer but which adds flush support, and use that class to handle all four {Input,Output}Streams.

Could probably be used in more places as well.