Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2010-12-05 17:37:06 -0500
committerMatthias Sohn2010-12-05 17:37:06 -0500
commit83dae99fb82570633f305e821ac26b0c39869726 (patch)
treedba06f010a546b87da1d5cf07b357272e167d681 /org.eclipse.egit.core.test
parent3a832b97c65258b3cfe724bf3fec7bfcc1a35e0b (diff)
downloadegit-83dae99fb82570633f305e821ac26b0c39869726.tar.gz
egit-83dae99fb82570633f305e821ac26b0c39869726.tar.xz
egit-83dae99fb82570633f305e821ac26b0c39869726.zip
[findbugs] Ensure closing writer in finally block
Change-Id: Ifd117e7a6c567d5e1a34192bf3b6db9964606638 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/TestRepository.java11
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java11
2 files changed, 16 insertions, 6 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index cf5e202be..a7b290b40 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -365,9 +365,14 @@ public class TestRepository {
*/
public void appendFileContent(File file, String content, boolean append)
throws IOException {
- FileWriter fw = new FileWriter(file, append);
- fw.append(content);
- fw.close();
+ FileWriter fw = null;
+ try {
+ fw = new FileWriter(file, append);
+ fw.append(content);
+ } finally {
+ if (fw != null)
+ fw.close();
+ }
}
/**
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
index f2301977a..7161708f5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
@@ -82,9 +82,14 @@ public class HistoryTest extends GitTestCase {
private File createFile(String name, String content) throws IOException {
File f = new File(workDir, name);
- FileWriter fileWriter = new FileWriter(f);
- fileWriter.write(content);
- fileWriter.close();
+ FileWriter fileWriter = null;
+ try {
+ fileWriter = new FileWriter(f);
+ fileWriter.write(content);
+ } finally {
+ if (fileWriter != null)
+ fileWriter.close();
+ }
return f;
}

Back to the top