From b5d31a8c83b0cc92710ef7ce6837c5eae6e7425d Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Thu, 14 Mar 2024 15:32:45 +0100 Subject: [PATCH] Add a C&S step for CompletionStagePublisher cancellation We're observing some RS TCK failures in slow CI conditions. --- .../java/mutiny/zero/internal/CompletionStagePublisher.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mutiny-zero/src/main/java/mutiny/zero/internal/CompletionStagePublisher.java b/mutiny-zero/src/main/java/mutiny/zero/internal/CompletionStagePublisher.java index ede1a3d..f5f71ea 100644 --- a/mutiny-zero/src/main/java/mutiny/zero/internal/CompletionStagePublisher.java +++ b/mutiny-zero/src/main/java/mutiny/zero/internal/CompletionStagePublisher.java @@ -86,8 +86,9 @@ public void request(long n) { @Override public void cancel() { - cancelled.set(true); - completableFuture.toCompletableFuture().cancel(false); + if (cancelled.compareAndSet(false, true)) { + completableFuture.toCompletableFuture().cancel(false); + } } } }