Balzanka / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Close-protecting OutputStream and InputStream wrappers #1367

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I propose to add two methods "OutputStream closeProtect(OutputStream)" and 
"InputStream closeProtect(InputStream)" to the ByteStreams class. The methods 
would take the given stream and return a wrapper that simply forwards all 
method calls except for "close()", so that calling "close()" on the returned 
stream will have no effect.

Use cases for this are for example cases where you wrap a stream into another 
stream and want to close the wrapper stream, but not the wrapped stream. I have 
a concrete use case for this that is described in this StackOverflow question: 
http://stackoverflow.com/q/15907105/396730

The methods could of course also have different names, e.g., "preventClosingOf" 
or "uncloseableStream".

Apache Commons IO has CloseShieldOutputStream and CloseShieldInputStream that 
have the same effect, but I prefer Guava and would think this is a worthy 
addition.

Original issue reported on code.google.com by phwend...@gmail.com on 10 Apr 2013 at 11:43

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 20 Nov 2013 at 10:23

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08