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
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate static voidcheckedGet(Future<Void> future) private voidvoidclose()private voidprivate voidvoidflush()private static InterruptedIOExceptionprivate booleanvoidwrite(byte[] buf, int pos, int cnt) voidwrite(int ch) Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Field Details
-
dst
-
copier
-
pending
-
-
Constructor Details
-
IsolatedOutputStream
Wraps an OutputStream.- Parameters:
out- stream to send all writes to.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
tryCleanClose
private boolean tryCleanClose() -
cleanClose
- Throws:
IOException
-
dirtyClose
- Throws:
IOException
-
checkClosed
- Throws:
IOException
-
execute
- Throws:
IOException
-
checkedGet
- Throws:
IOException
-
interrupted
-