Skip to content
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