-
Notifications
You must be signed in to change notification settings - Fork 937
added part count validation for download request #6353
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
...ava/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java
Outdated
Show resolved
Hide resolved
...ava/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java
Outdated
Show resolved
Hide resolved
...ava/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java
Outdated
Show resolved
Hide resolved
...ava/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java
Outdated
Show resolved
Hide resolved
...ava/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java
Outdated
Show resolved
Hide resolved
...st/java/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloadTestUtil.java
Outdated
Show resolved
Hide resolved
@@ -198,4 +202,14 @@ private GetObjectRequest nextRequest(int nextPartToGet) { | |||
} | |||
}); | |||
} | |||
|
|||
private void validatePartsCount(int currentGetCount) { |
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.
Is there any way to simulate this error for testing? If not, it's fine.
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.
Added unit test using a mock S3 client
|
||
synchronized (lock) { | ||
if (totalParts != null && nextPartToGet > totalParts) { | ||
log.debug(() -> String.format("Completing multipart download after a total of %d parts downloaded.", totalParts)); | ||
validatePartsCount(currentPart); |
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.
I believe we should remove validation from here because it's totally valid for publisher to send more data after subscription.
https://github.com/reactive-streams/reactive-streams-jvm
8 If a Subscription is cancelled its Subscriber MUST eventually stop being signaled.
💡 The intent of this rule is to make sure that Publishers respect a Subscriber’s request to cancel a Subscription when Subscription.cancel() has been called. The reason for eventually is because signals can have propagation delay due to being asynchronous.
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.
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.
Can we add some tests cases for this new validation?
I think we need a test with an actual multipart s3AsyncClient, ie:
We can still mock the http client but that might be a hard test to mock, let me think about it to see if there is a way to do it. |
|
Motivation and Context
For the part get request for S3 transfer manager, When a response is received, the S3 Transfer Manager MUST check the value of ContentRange and validate that it matches with the expected range for the specific part number. After all requests have been sent, we should validate that the total number of part GET requests sent matches with the expected PartsCount. This PR implements the validation.
Modifications
Added validation method in MultipartDownloaderSubscriber class
Testing
Added wiremock test for failed test
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License