-
Notifications
You must be signed in to change notification settings - Fork 964
Fix NPE issue in multipart S3 client #6594
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
Open
zoewangg
wants to merge
6
commits into
master
Choose a base branch
from
zoewang/emptyBodyWithUnknownContentLength
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+116
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ct containing empty content without supplying a content length
zoewangg
commented
Nov 28, 2025
...va/software/amazon/awssdk/services/s3/internal/multipart/utils/MultipartUploadTestUtils.java
Outdated
Show resolved
Hide resolved
L-Applin
approved these changes
Nov 28, 2025
RanVaknin
reviewed
Nov 28, 2025
...tware/amazon/awssdk/services/s3/internal/multipart/UploadWithUnknownContentLengthHelper.java
Show resolved
Hide resolved
...tware/amazon/awssdk/services/s3/internal/multipart/UploadWithUnknownContentLengthHelper.java
Show resolved
Hide resolved
RanVaknin
approved these changes
Dec 1, 2025
|
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 2, 2025
* Fix NPE issue thrown when using multipart S3 client to upload an object containing empty content without supplying a content length * Apply suggestion from @zoewangg * Address feedback
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Motivation and Context
Fix NPE issue thrown when using multipart S3 client to upload an object containing empty content without supplying a content length. Fix #6464
When uploading an empty object with unknown content length using the S3 multipart client, a NullPointerException was thrown because the code didn't handle the case
where no async request body chunks are received before the stream completes.
Modifications
• Modified UploadWithUnknownContentLengthHelper to handle empty streams by checking if any async request body has been received before onComplete() is called
• Added null check in onNext() to fail gracefully if a null async request body is passed
• Renamed isFirstAsyncRequestBody to firstAsyncRequestBodyReceived for better clarity
• When no request body is received, use AsyncRequestBody.empty() for single object upload
Testing
• Added new tests
Types of changes
• [x] Bug fix (non-breaking change which fixes an issue)
• [ ] New feature (non-breaking change which adds functionality)
Checklist
• [x] I have read the CONTRIBUTING document
• [x] Local run of mvn install succeeds
• [x] 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
• [x] I have added tests to cover my changes
• [x] All new and existing tests passed
• [x] 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
• [x] I confirm that this pull request can be released under the Apache 2 license