-
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
base: master
Are you sure you want to change the base?
Conversation
…ct containing empty content without supplying a content length
...va/software/amazon/awssdk/services/s3/internal/multipart/utils/MultipartUploadTestUtils.java
Outdated
Show resolved
Hide resolved
|
|
|
||
| @Override | ||
| public void onNext(CloseableAsyncRequestBody asyncRequestBody) { | ||
| if (asyncRequestBody == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add isDone = true here just like with onError() ?
| public void onNext(CloseableAsyncRequestBody asyncRequestBody) { | ||
| if (asyncRequestBody == null) { | ||
| NullPointerException exception = new NullPointerException("asyncRequestBody passed to onNext MUST NOT be null."); | ||
| multipartUploadHelper.failRequestsElegantly(futures, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noob question, I assume there is a reason we use failRequestsElegantly here. The Reactive Streams spec requires throwing NPE when onNext() receives null. Is there a reason we complete the future exceptionally but don't throw to the caller?



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