Skip to content

Fix a race condition where the third upload part request was sent bef… #4260

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

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ public void onNext(AsyncRequestBody asyncRequestBody) {
subscription.cancel();
} else {
uploadId = createMultipartUploadResponse.uploadId();
uploadIdFuture.complete(uploadId);
log.debug(() -> "Initiated a new multipart upload, uploadId: " + uploadId);

sendUploadPartRequest(uploadId, firstRequestBody);
sendUploadPartRequest(uploadId, asyncRequestBody);

// We need to complete the uploadIdFuture *after* the first two requests have been sent
uploadIdFuture.complete(uploadId);
Copy link
Contributor Author

@zoewangg zoewangg Aug 3, 2023

Choose a reason for hiding this comment

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

The race condition is that the third request on line 189 could be executed before the first and second request, so the fix is completing uploadIdFuture after the first two requests have been sent.

}
});
CompletableFutureUtils.forwardExceptionTo(returnFuture, createMultipartUploadFuture);
Expand Down