-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3: getObject, ResponseInputStream close not working as expected. #2117
Comments
It looks like
I'm not sure what is the expected behavior of |
@debora-ito It's fine that there is a abort() call for this. but it simply does not work well when you use wrappers to actually read the contents of a stream e.g. a simple InputStreamReader, or GZipInputStream etc. Those are often returned directly like below, at that point the abort() and the whole S3 backend is lost to the caller.
And the only thing that remains of the contract is the close() operation. In the java docs these are very clearly documented.
I do not consider it a issue that on EOF the connection is returned to the pool. But if for some reason it gets closed early, continuing to read in the close() call is effectively not part of the contract. And it does cause long waits when something fails. e.g. when using a try-resource statement like below.
So i consider it a contract violation of the InputStream#close() contract that getObject implements a InputStream and on close read is continued. |
This appears to happen with other streams as well. I'm reading from a Kinesis Video stream that returns a |
I can use the same workaround by doing: ResponseInputStream<GetMediaResponse> inputStream = (ResponseInputStream<GetMediaResponse>) kvsStreamTrackObject.getInputStream();
inputStream.abort(); ...although I then also have to call |
…bda3b78d9 Pull request: release <- staging/8dbcb073-2c84-4481-bbc1-358bda3b78d9
I fully agree to @JstDust. As some temporary workaround one would have to create its own @debora-ito IMHO there is no big thing to clarify as this is just the contract that every Java developer would expect. I can imagine that it is a huge effort to get all the S3 clients for every different programming languages perfect and it may also be tricky to consider changing existing behavior but this IMHO the way to go.
Could we expect things like this to be solved out of the box by the SDK from the top #1 hyperscaler? |
Describe the bug
When you invoke close on ResponseInputStream from the getObject before you reach the end of the data. The stream will not immediately(/within reasonable time) close on big files.
Expected Behavior
When invoking close on an ResponseInputStream you would expect a close within at least a few seconds.
Current Behavior
It does not close until it did a complete read of the stream internally. (this seems related to connection recycling internally).
Steps to Reproduce
Possible Solution
Context
I was trying to create a test case for a wrapper i created for handling network related issues (e.g. connection reset). Where i would simply track the position in the stream and use a range request when the connection fails, to continue the stream transparently.
When testing it by creating a wrapper around the ResponseInputStream that throws randomly a IO exception i noticed the extreme delay when closing the ResponseInputStream.
Workaround
Your Environment
The text was updated successfully, but these errors were encountered: