From b5c313639f094697029b8e57ab22dd344e68821d Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 1 Mar 2015 23:08:51 +0100 Subject: [findBugs] Ensure that FileOutputStream is closed Change-Id: Icdfb04dd7a549c544993f6c5d118279cb6a6b498 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/egit/core/test/GitTestCase.java | 12 ++++++++---- 1 file 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; } } -- cgit v1.2.3