-
Couldn't load subscription status.
- Fork 947
Closed
Labels
documentationThis is a problem with documentation.This is a problem with documentation.p2This is a standard priority issueThis is a standard priority issue
Description
Describe the issue
Using a ReponseInputStream in a try-with-resources block combined with a call to abort can lead to a 'premature end of stream' error.
As an example, the following code
s3Client.putObject(b -> b.bucket(bucketName).key("object"), RequestBody.fromString("abcd"));
try (var object = s3Client.getObject(GetObjectRequest.builder().bucket(bucketName).key("object").build())) {
object.abort();
}
produces an exception with this stack trace
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 4; received: 0)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:198)
at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:101)
at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:142)
at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)
at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:172)
at java.base/java.io.FilterInputStream.close(FilterInputStream.java:170)
at java.base/java.io.FilterInputStream.close(FilterInputStream.java:170)
at software.amazon.awssdk.core.io.SdkFilterInputStream.close(SdkFilterInputStream.java:83)
Is this the expected behaviour? The javadoc for ReponseInputStream seems to suggest that abort should be used instead of close. That does make it rather difficult to use abort in combination with try-with-resources.
Links
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/ResponseInputStream.html
Metadata
Metadata
Assignees
Labels
documentationThis is a problem with documentation.This is a problem with documentation.p2This is a standard priority issueThis is a standard priority issue