aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.16k stars 840 forks source link

Do not add chunk data for empty ByteBuffer #5320

Closed davidh44 closed 3 months ago

davidh44 commented 3 months ago

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

Checklist

License

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud