-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Describe the bug
ByteStreamJVM.writeToOutputStream is documented as This method does not flush or close the given OutputStream. but does close the stream (indirectly).
outputStream.sink() ultimately creates an okio.OutputStreamSink that has override fun close() = out.close()
We ran across this writing S3 objects (in a loop) to a ZipOutputStream that was closed after the first call to body.writeOutputStream(...).
Regression Issue
- Select this option if this issue appears to be a regression.
Expected behavior
Expecting that writing to a stream does not close it. One may wish to write further data to the stream, as is the case with a ZipOutputStream with multiple entries.
Current behavior
writeOutputStream closes the stream, contradicting the documented behaviour.
Steps to Reproduce
Pass a stream into any ByteStream.writeToOutputStream and check its state after the call.
Possible Solution
Wrap in some form of close-suppressing sink, or a close-suppressing OutputStream.
We worked around this by doing body.toInputStream().copyTo(outputStream) (which isn't great, that InputStream may or may not need to be closed...)
Context
Good for now - pls restore the documented functionality!
AWS SDK for Kotlin version
1.3.52 (unclear where the regression happened, or if this ever worked as documented)
Platform (JVM/JS/Native)
JVM
Operating system and version
any