aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2012-01-15 11:22:52 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2012-01-15 11:22:52 +0100
commite875c905d310153165c5bdb24ead55d98596923a (patch)
treeb247debd7c714838109a23a0f103dc1a17a54de4 /org.eclipse.jgit.test/tst/org/eclipse/jgit/storage
parent02729810f9246b9f332945f730d65c68f118d489 (diff)
downloadjgit-e875c905d310153165c5bdb24ead55d98596923a.tar.gz
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.test/tst/org/eclipse/jgit/storage')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java6
2 files changed, 5 insertions, 5 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
index cfb526d63b..c099bb0bd3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
@@ -50,7 +50,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -69,6 +68,7 @@ import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.transport.PackedObjectInfo;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.io.SafeBufferedOutputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -178,7 +178,7 @@ public class AbbreviationTest extends LocalDiskRepositoryTestCase {
File idxFile = new File(packDir, packName + ".idx");
File packFile = new File(packDir, packName + ".pack");
FileUtils.mkdir(packDir, true);
- OutputStream dst = new BufferedOutputStream(new FileOutputStream(
+ OutputStream dst = new SafeBufferedOutputStream(new FileOutputStream(
idxFile));
try {
PackIndexWriter writer = new PackIndexWriterV2(dst);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java
index ba9aa24991..0a5e9feb81 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java
@@ -51,7 +51,6 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -72,6 +71,7 @@ import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.PackWriter;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.io.SafeBufferedOutputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -236,14 +236,14 @@ public class ConcurrentRepackTest extends RepositoryTestCase {
NullProgressMonitor m = NullProgressMonitor.INSTANCE;
OutputStream out;
- out = new BufferedOutputStream(new FileOutputStream(files[0]));
+ out = new SafeBufferedOutputStream(new FileOutputStream(files[0]));
try {
pw.writePack(m, m, out);
} finally {
out.close();
}
- out = new BufferedOutputStream(new FileOutputStream(files[1]));
+ out = new SafeBufferedOutputStream(new FileOutputStream(files[1]));
try {
pw.writeIndex(out);
} finally {