diff options
author | Andreas Fankhauser hiddenalpha.ch | 2023-09-06 15:03:29 +0200 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2023-09-06 15:03:29 +0200 |
commit | 06f775e2af81c0ab186303fe72c4bfa362df6a2f (patch) | |
tree | 32eb4ed594cee8a2c32aa500403156865dfc77e1 | |
parent | 1dcdf5611131223d77b96596b64adea01a36540a (diff) | |
download | UnspecifiedGarbage-06f775e2af81c0ab186303fe72c4bfa362df6a2f.zip UnspecifiedGarbage-06f775e2af81c0ab186303fe72c4bfa362df6a2f.tar.gz |
Introduce IgnoreCloseOutputStream
-rw-r--r-- | src/main/java/ch/hiddenalpha/unspecifiedgarbage/octetstream/IgnoreCloseOutputStream.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/ch/hiddenalpha/unspecifiedgarbage/octetstream/IgnoreCloseOutputStream.java b/src/main/java/ch/hiddenalpha/unspecifiedgarbage/octetstream/IgnoreCloseOutputStream.java new file mode 100644 index 0000000..d17172a --- /dev/null +++ b/src/main/java/ch/hiddenalpha/unspecifiedgarbage/octetstream/IgnoreCloseOutputStream.java @@ -0,0 +1,31 @@ +package ch.hiddenalpha.unspecifiedgarbage.octetstream; + + +/** + * <p>Suppresses to close the underlying {@link java.io.OutputStream} when + * close gets called.</p> + * + * <p>This can be needed for example we get a outputStream passed from caller + * and we have to pass it further down to another callee. Which may close the + * passed stream. But this is unlucky if our caller (or we ourself) needs to + * continue writing to the original stream after we have completed writing what + * we were supposed to write.</p> + * + * <p>For example imagine we're creating a tar archive and pass our + * outputStream down to some source which will write a tar entries payload to + * the stream and in the end closes the sink. This would make it impossible for + * us to write any more entries to that stream.</p> + * + * <p>WARN: Think before using this filter! Blindly using it without + * understanding what this is for, you risk to produce resource-leaks.</p> + */ +public class IgnoreCloseOutputStream extends java.io.FilterOutputStream { + + public IgnoreCloseOutputStream(java.io.OutputStream out) { + super(out); + } + + @Override public void close() {/*no-op*/} + +} + |