Package org.eclipse.jgit.util.io
Class IsolatedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.util.io.IsolatedOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class IsolatedOutputStream extends OutputStream
OutputStream isolated from interrupts.Wraps an OutputStream to prevent interrupts during writes from being made visible to that stream instance. This works around buggy or difficult OutputStream implementations like JSch that cannot gracefully handle an interrupt during write.
Every write (or flush) requires a context switch to another thread. Callers should wrap this stream with
BufferedOutputStream
using a suitable buffer size to amortize the cost of context switches.- Since:
- 4.6
-
-
Constructor Summary
Constructors Constructor Description IsolatedOutputStream(OutputStream out)
Wraps an OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(byte[] buf, int pos, int cnt)
void
write(int ch)
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
IsolatedOutputStream
public IsolatedOutputStream(OutputStream out)
Wraps an OutputStream.- Parameters:
out
- stream to send all writes to.
-
-
Method Detail
-
write
public void write(int ch) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] buf, int pos, int cnt) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-