aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit
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
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')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java4
-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
3 files changed, 7 insertions, 7 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
index 8dca7b4260..a183a1ce73 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
@@ -45,7 +45,6 @@ package org.eclipse.jgit.diff;
import static org.junit.Assert.assertEquals;
-import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -62,6 +61,7 @@ import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.filter.PathFilter;
import org.eclipse.jgit.util.RawParseUtils;
import org.eclipse.jgit.util.io.DisabledOutputStream;
+import org.eclipse.jgit.util.io.SafeBufferedOutputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -267,7 +267,7 @@ public class DiffFormatterTest extends RepositoryTestCase {
write(new File(folder, "folder.txt"), "folder change");
ByteArrayOutputStream os = new ByteArrayOutputStream();
- DiffFormatter df = new DiffFormatter(new BufferedOutputStream(os));
+ DiffFormatter df = new DiffFormatter(new SafeBufferedOutputStream(os));
df.setRepository(db);
df.setPathFilter(PathFilter.create("folder"));
DirCacheIterator oldTree = new DirCacheIterator(db.readDirCache());
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 {