Skip to content

Do not add chunk data for empty ByteBuffer #5320

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

Merged
merged 7 commits into from
Jun 21, 2024

Conversation

davidh44
Copy link
Contributor

@davidh44 davidh44 commented Jun 21, 2024

Motivation and Context

When doing S3 PutObject with flexible checksums with S3AsyncClient, the ChecksumCalculatingAsyncRequestBody adds chunk headers and trailers to each chunk. We should skip this if there is a non-final empty chunk of length 0, as it causes an error to be thrown

S3Exception: You did not provide the number of bytes specified by the Content-Length HTTP header

Modifications

In onNext(), return the ByteBuffer as is, if it is empty and non-final chunk

Testing

added unit tests, performed one-off integ tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@davidh44 davidh44 requested a review from a team as a code owner June 21, 2024 00:39
@@ -224,5 +224,17 @@
<artifactId>jimfs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably avoid circular dependency in the SDK. It'll likely cause more dependency issues in the future. (Side note, I didn't know you could use exclusions trick to work around the issue)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed integ test, one-off testing and unit test should be sufficient

@@ -197,9 +197,11 @@ public void onNext(ByteBuffer byteBuffer) {
checksumBytes = checksum.getChecksumBytes();
ByteBuffer allocatedBuffer = getFinalChecksumAppendedChunk(byteBuffer);
wrapped.onNext(allocatedBuffer);
} else {
} else if (byteBuffer.remaining() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: hasRemaining()?

Copy link

@davidh44 davidh44 merged commit 9fec27c into master Jun 21, 2024
17 checks passed
@davidh44 davidh44 deleted the hdavidh/do-not-add-chunk-data-for-empty-bytebuffer branch June 21, 2024 20:12
akidambisrinivasan pushed a commit to akidambisrinivasan/aws-sdk-java-v2 that referenced this pull request Jun 28, 2024
* Do not add chunk data for empty ByteBuffer

* Do not add chunk data for empty ByteBuffer

* Add unit test

* Add changelog

* Remove integ test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants