From 8208da2f59ca13d93bd396e2f8189b0fefdb764d Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Sun, 13 Nov 2016 11:24:41 -0800 Subject: Deprecate SafeBufferedOutputStream Java 8 fixed the silent flush during close issue by FilterOutputStream (base class of BufferedOutputStream) using try-with-resources to close the stream, getting a behavior matching what JGit's SafeBufferedOutputStream was doing: try { flush(); } finally { out.close(); } With Java 8 as the minimum required version to run JGit it is no longer necessary to override close() or have this class. Deprecate the class, and use the JRE's version of close. Change-Id: Ic0584c140010278dbe4062df2e71be5df9a797b3 --- .../jgit/util/io/SafeBufferedOutputStream.java | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/io') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SafeBufferedOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SafeBufferedOutputStream.java index 68f250da09..84c339889b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SafeBufferedOutputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SafeBufferedOutputStream.java @@ -43,20 +43,13 @@ package org.eclipse.jgit.util.io; import java.io.BufferedOutputStream; -import java.io.IOException; import java.io.OutputStream; /** - * A BufferedOutputStream that throws an error if the final flush fails on - * close. - *

- * Java's BufferedOutputStream swallows errors that occur when the output stream - * tries to write the final bytes to the output during close. This may result in - * corrupted files without notice. - *

+ * @deprecated use BufferedOutputStream in Java 8 and later. */ +@Deprecated public class SafeBufferedOutputStream extends BufferedOutputStream { - /** * @see BufferedOutputStream#BufferedOutputStream(OutputStream) * @param out @@ -76,13 +69,4 @@ public class SafeBufferedOutputStream extends BufferedOutputStream { public SafeBufferedOutputStream(OutputStream out, int size) { super(out, size); } - - @Override - public void close() throws IOException { - try { - flush(); - } finally { - super.close(); - } - } } -- cgit v1.2.3