diff --git a/core/src/main/java/hudson/CloseProofOutputStream.java b/core/src/main/java/hudson/CloseProofOutputStream.java index 08a3abca78..08e797fa1c 100644 --- a/core/src/main/java/hudson/CloseProofOutputStream.java +++ b/core/src/main/java/hudson/CloseProofOutputStream.java @@ -1,12 +1,14 @@ package hudson; -import java.io.FilterOutputStream; +import hudson.util.DelegatingOutputStream; + import java.io.OutputStream; /** + * {@link OutputStream} that blocks {@link #close()} method. * @author Kohsuke Kawaguchi */ -public class CloseProofOutputStream extends FilterOutputStream { +public class CloseProofOutputStream extends DelegatingOutputStream { public CloseProofOutputStream(OutputStream out) { super(out); } diff --git a/core/src/main/java/hudson/maven/ProcessCache.java b/core/src/main/java/hudson/maven/ProcessCache.java index 38200107d0..6bb9fc8d3f 100644 --- a/core/src/main/java/hudson/maven/ProcessCache.java +++ b/core/src/main/java/hudson/maven/ProcessCache.java @@ -1,22 +1,22 @@ package hudson.maven; import hudson.Util; -import hudson.util.NullStream; import hudson.model.BuildListener; import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.VirtualChannel; import hudson.tasks.Maven.MavenInstallation; +import hudson.util.DelegatingOutputStream; +import hudson.util.NullStream; -import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import java.util.WeakHashMap; import java.util.Properties; +import java.util.WeakHashMap; /** * Hold on to launched Maven processes so that multiple builds @@ -182,7 +182,7 @@ final class ProcessCache { private static final long serialVersionUID = 1L; } - static class RedirectableOutputStream extends FilterOutputStream { + static class RedirectableOutputStream extends DelegatingOutputStream { public RedirectableOutputStream(OutputStream out) { super(out); } diff --git a/core/src/main/java/hudson/util/CountingOutputStream.java b/core/src/main/java/hudson/util/CountingOutputStream.java index 9853508455..74fcc0f796 100644 --- a/core/src/main/java/hudson/util/CountingOutputStream.java +++ b/core/src/main/java/hudson/util/CountingOutputStream.java @@ -9,7 +9,7 @@ import java.io.OutputStream; * * @author Kohsuke Kawaguchi */ -public class CountingOutputStream extends FilterOutputStream { +public class CountingOutputStream extends DelegatingOutputStream { private int count = 0; public int getCount() { diff --git a/core/src/main/java/hudson/util/DelegatingOutputStream.java b/core/src/main/java/hudson/util/DelegatingOutputStream.java new file mode 100644 index 0000000000..a5307b98ad --- /dev/null +++ b/core/src/main/java/hudson/util/DelegatingOutputStream.java @@ -0,0 +1,38 @@ +package hudson.util; + +import java.io.FilterOutputStream; +import java.io.OutputStream; +import java.io.IOException; + +/** + * Works like {@link FilterOutputStream} except its performance problem. + * + * @author Kohsuke Kawaguchi + */ +public abstract class DelegatingOutputStream extends OutputStream { + protected OutputStream out; + + protected DelegatingOutputStream(OutputStream out) { + this.out = out; + } + + public void write(int b) throws IOException { + out.write(b); + } + + public void write(byte[] b) throws IOException { + out.write(b); + } + + public void write(byte[] b, int off, int len) throws IOException { + out.write(b, off, len); + } + + public void flush() throws IOException { + out.flush(); + } + + public void close() throws IOException { + out.close(); + } +}