]> source.dussan.org Git - jgit.git/commit
FS#runProcess: Fix OutputStream left unclosed after IOException 63/119463/6
authorDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 15 Mar 2018 04:44:00 +0000 (13:44 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Sat, 24 Mar 2018 21:15:43 +0000 (22:15 +0100)
commit76b4ed6a8503ea3f9514d931bf97e85910c319f5
tree54abf38040a022be9cff7aaa8d2e08da0be4f6e3
parent7719a406bf0148269af43d6461c07752c72806f5
FS#runProcess: Fix OutputStream left unclosed after IOException

The runProcess method creates an OutputStream that is not managed by
a try-with-resource because it's manually closed and any IOException
raised by the close() method is explicitly ignored.

Suppress the resource warning with an explanatory comment.

Enclose the call to StreamGobbler#copy in an inner try-block, and move
the call to close() inside its finally block. This prevents the stream
from being left unclosed if StreamGobbler#copy raises IOException.

Change-Id: Idca9adfc4d87e0989d787ad8239c055c0c849814
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java