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.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ExecutorService | |
| private final OutputStream | |
| private Future |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private static void | |
| private void | |
| public void | close()
Overrides java. Implements java. Closes this output stream and releases any system resources associated with this stream. |
| private void | |
| private void | |
| public void | flush()
Overrides java. Implements java. Flushes this output stream and forces any buffered output bytes to be written out. |
| private static InterruptedIOException | |
| private boolean | |
| public void | write(int
the ch)byte.Implements abstract java. Writes the specified byte to this output stream. |
| public void | write(byte[]
the data. buf, int the start offset in the data. pos, int the number of bytes to write. cnt)Overrides java. Writes |
| copier | back to summary |
|---|---|
| private final ExecutorService copier | |
| dst | back to summary |
|---|---|
| private final OutputStream dst | |
| pending | back to summary |
|---|---|
| private Future<Void> pending | |
| IsolatedOutputStream | back to summary |
|---|---|
| public IsolatedOutputStream(OutputStream out) Wraps an OutputStream.
| |
| checkClosed | back to summary |
|---|---|
| private void checkClosed() throws IOException | |
| checkedGet | back to summary |
|---|---|
| private static void checkedGet(Future<Void> future) throws IOException | |
| cleanClose | back to summary |
|---|---|
| private void cleanClose() throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |
| dirtyClose | back to summary |
|---|---|
| private void dirtyClose() throws IOException | |
| execute | back to summary |
|---|---|
| private void execute(Callable<Void> task) throws IOException | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Doc from java. Flushes this output stream and forces any buffered output bytes
to be written out. The general contract of If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
| |
| interrupted | back to summary |
|---|---|
| private static InterruptedIOException interrupted(InterruptedException c) | |
| tryCleanClose | back to summary |
|---|---|
| private boolean tryCleanClose() | |
| write | back to summary |
|---|---|
| public void write(int ch) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |
| write | back to summary |
|---|---|
| public void write(byte[] buf, int pos, int cnt) throws IOException Overrides java. Doc from java. Writes
If
If
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final AtomicInteger |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Thread | newThread(Runnable
a runnable to be executed by new thread instance r)Implements java. Constructs a new unstarted |
| cnt | back to summary |
|---|---|
| private static final AtomicInteger cnt | |
| NamedThreadFactory | back to summary |
|---|---|
| private NamedThreadFactory() | |
| newThread | back to summary |
|---|---|
| public Thread newThread(Runnable r) Implements java. Doc from java. Constructs a new unstarted | |