Skip to content

Add validation for buffer lengthwhen multipart upload with unknown contentlength#7024

Open
Fred1155 wants to merge 3 commits into
masterfrom
bole/multipart_upload_buffersize_validation
Open

Add validation for buffer lengthwhen multipart upload with unknown contentlength#7024
Fred1155 wants to merge 3 commits into
masterfrom
bole/multipart_upload_buffersize_validation

Conversation

@Fred1155

@Fred1155 Fred1155 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

S3 multipart uploads with unknown content length could hang when apiCallBufferSizeInBytes was less than 2 × minimumPartSizeInBytes. The unknown-length path holds the first part in memory while buffering the second, so it needs room for two parts; a smaller buffer causes a circular wait before any HTTP request is made, so no timeout applies.

Modifications

  • UploadWithUnknownContentLengthHelper: fail fast with a descriptive message instead of deadlocking.
  • MultipartConfiguration: documented the 2× requirement on apiCallBufferSizeInBytes.
  • Only the unknown-length path is affected. Known-length uploads and default configs (buffer defaults to 4 × part size) are unchanged.

Testing

Added unit test and ran local integration test.

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

@Fred1155 Fred1155 requested a review from a team as a code owner June 9, 2026 20:58
@Fred1155 Fred1155 added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Jun 9, 2026

verifyFailureWithMessage(future, "must be at least 2 x minimumPartSizeInBytes");

verify(asyncRequestBody, times(0)).splitCloseable(any(Consumer.class));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit nonblocking: never() instead of times(0)

* Default value: If not specified, the SDK will use the equivalent of four parts worth of memory, so 32 Mib by default.
* <p>
* When uploading content with an unknown content length, this value
* must be at least 2 x {@code minimumPartSizeInBytes}. The unknown-length upload path buffers one part while it buffers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit nonblocking: {@link #minimumPartSizeInBytes} instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants