question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid data returned from "InputStream.read()" on an empty S3 Object

See original GitHub issue

Describe 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:open
  • Created 10 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
yasminetalbycommented, Nov 16, 2022

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

1reaction
yasminetalbycommented, Nov 9, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found