Skip to content

Commit 466e687

Browse files
authored
Fix a race condition where the third upload part request was sent before the second one (#4260)
1 parent 85a1fd7 commit 466e687

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/multipart/UploadWithUnknownContentLengthHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,13 @@ public void onNext(AsyncRequestBody asyncRequestBody) {
174174
subscription.cancel();
175175
} else {
176176
uploadId = createMultipartUploadResponse.uploadId();
177-
uploadIdFuture.complete(uploadId);
178177
log.debug(() -> "Initiated a new multipart upload, uploadId: " + uploadId);
179178

180179
sendUploadPartRequest(uploadId, firstRequestBody);
181180
sendUploadPartRequest(uploadId, asyncRequestBody);
181+
182+
// We need to complete the uploadIdFuture *after* the first two requests have been sent
183+
uploadIdFuture.complete(uploadId);
182184
}
183185
});
184186
CompletableFutureUtils.forwardExceptionTo(returnFuture, createMultipartUploadFuture);

0 commit comments

Comments
 (0)