diff options
author | Matthias Sohn | 2015-03-01 22:08:51 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-03-01 22:08:51 +0000 |
commit | b5c313639f094697029b8e57ab22dd344e68821d (patch) | |
tree | 4a25f643df374f48fc8b72c4166bfeb7cf109175 /org.eclipse.egit.core.test | |
parent | 5df56a377610a6bc60a142b7838cf10e57c8f7e6 (diff) | |
download | egit-b5c313639f094697029b8e57ab22dd344e68821d.tar.gz egit-b5c313639f094697029b8e57ab22dd344e68821d.tar.xz egit-b5c313639f094697029b8e57ab22dd344e68821d.zip |
[findBugs] Ensure that FileOutputStream is closed
Change-Id: Icdfb04dd7a549c544993f6c5d118279cb6a6b498
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r-- | org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java index e2f22369f9..d0d0af1511 100644 --- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java +++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java @@ -101,10 +101,14 @@ public abstract class GitTestCase { byte[] readFully = IO.readFully(file); FileUtils.delete(file); FileOutputStream fileOutputStream = new FileOutputStream(file); - byte[] truncatedData = new byte[readFully.length - 1]; - System.arraycopy(readFully, 0, truncatedData, 0, truncatedData.length); - fileOutputStream.write(truncatedData); - fileOutputStream.close(); + try { + byte[] truncatedData = new byte[readFully.length - 1]; + System.arraycopy(readFully, 0, truncatedData, 0, + truncatedData.length); + fileOutputStream.write(truncatedData); + } finally { + fileOutputStream.close(); + } return id; } } |