Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg2012-01-15 10:22:52 +0000
committerMatthias Sohn2012-01-15 10:22:52 +0000
commite875c905d310153165c5bdb24ead55d98596923a (patch)
treeb247debd7c714838109a23a0f103dc1a17a54de4 /org.eclipse.jgit.junit
parent02729810f9246b9f332945f730d65c68f118d489 (diff)
downloadjgit-e875c905d310153165c5bdb24ead55d98596923a.tar.gz
jgit-e875c905d310153165c5bdb24ead55d98596923a.tar.xz
jgit-e875c905d310153165c5bdb24ead55d98596923a.zip
Make sure all bytes are written to files on close, or get an error.
Java's BufferedOutputStream swallows any errors that occur when flushing the buffer in close(). This class overrides close to make sure an error during the final flush is reported back to the caller. Change-Id: I74a82b31505fadf8378069c5f6554f1033c28f9b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index eea7811c09..f4a3a6289d 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -43,9 +43,9 @@
package org.eclipse.jgit.junit;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -61,10 +61,10 @@ import java.util.Set;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEditor;
-import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheEditor.DeletePath;
import org.eclipse.jgit.dircache.DirCacheEditor.DeleteTree;
import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
+import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.ObjectWritingException;
@@ -97,6 +97,7 @@ import org.eclipse.jgit.storage.pack.PackWriter;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.io.SafeBufferedOutputStream;
/**
* Wrapper to make creating test data easier.
@@ -623,7 +624,7 @@ public class TestRepository<R extends Repository> {
OutputStream out;
pack = nameFor(odb, name, ".pack");
- out = new BufferedOutputStream(new FileOutputStream(pack));
+ out = new SafeBufferedOutputStream(new FileOutputStream(pack));
try {
pw.writePack(m, m, out);
} finally {
@@ -632,7 +633,7 @@ public class TestRepository<R extends Repository> {
pack.setReadOnly();
idx = nameFor(odb, name, ".idx");
- out = new BufferedOutputStream(new FileOutputStream(idx));
+ out = new SafeBufferedOutputStream(new FileOutputStream(idx));
try {
pw.writeIndex(out);
} finally {

Back to the top