Invalid data returned from "InputStream.read()" on an empty S3 Object
See original GitHub issueDescribe the bug
I have an empty S3 object. When I create an InputStream to that object and invoke “read()” I get back an int “212”.
Expected Behavior
I would expect InputStream.read()
to an empty S3Object to return -1
.
Current Behavior
Currently it returns a single byte 212
.
Reproduction Steps
When executed against a 0 byte (empty) S3Object the following code returns 212
. It should return -1
var getObjectRequest =
GetObjectRequest.builder()
.bucket("bucket")
.key(
"emptyobject")
.build();
try (var fileContent =
s3Client.getObject(getObjectRequest, ResponseTransformer.toInputStream())) {
System.out.println(fileContent.read());
}
Possible Solution
I don’t know but the problem appears to be in the software.amazon.awssdk.services.s3.checksums.ChecksumValidatingInputStream
class. That is where the result diverges from using something like InputStream.readAllBytes()
.
Additional Information/Context
No response
AWS Java SDK version used
2.17.283
JDK version used
17
Operating System and version
Windows 11
Issue Analytics
- State:
- Created 10 months ago
- Comments:5
Top Results From Across the Web
Downloaded an Amazon S3 file doesn't contain data
This app lets you download an object located in an S3 bucket to your browser. enter image description here. The downloaded Object is...
Read more >S3ObjectInputStream (AWS SDK for Java - 1.12.362)
Input stream representing the content of an S3Object . ... Returns the value of super.available() if the result is nonzero, or 1 otherwise....
Read more >[S3] Select is broken on large-ish files · Issue #1296 - GitHub
The problem is we have a usability issue with the S3 select API in the SDK that we need to address. When you...
Read more >ECS Data Access Guide - Dell
When creating a bucket or object with empty content, ECS returns 400 invalid content-length value, which differs from AWS which returns 400 Bad...
Read more >Programmer Guide: Code Samples - JetS3t
The example above will create an empty object in S3, which isn't very useful. ... S3Object's can contain any data available from an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @youngm ,
Update: This bug has been added to the teams backlog. This issue submission will be updated and closed upon resolution.
Thank you very much for bringing this up to our attention.
Sincerely,
Yasmine
Of course. Thank you very much for bringing up this behavior to our attention, your feedback is very valuable to the team. I am glad to hear that you have been able to workaround the issue. I will post all updates regarding this in the comment section.
Best regards,
Yasmine