Skip to content

Commit 9e746e9

Browse files
committed
Update whenComplete to include a synchronization lock
1 parent 9837072 commit 9e746e9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/AsyncBufferingSubscriber.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ public AsyncBufferingSubscriber(Function<T, CompletableFuture<?>> consumer,
5656
returnFuture.whenComplete((r, t) -> {
5757
if (t != null) {
5858
requestsInFlight.forEach(f -> f.cancel(true));
59-
if (subscription != null) {
60-
subscription.cancel();
59+
synchronized (this) {
60+
if (subscription != null) {
61+
subscription.cancel();
62+
}
6163
}
6264
}
6365
});

0 commit comments

Comments
 (0)