From cdfc1d1f5b99bf401dd9d0428fb6e19104a05448 Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Mon, 23 Oct 2023 10:19:24 +0200 Subject: [PATCH] Fix termination of the fallback virtual thread executor --- .../FallbackVirtualThreadsExecutorService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/FallbackVirtualThreadsExecutorService.java b/extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/FallbackVirtualThreadsExecutorService.java index 01c89c19481f9..b2fa837d6df9e 100644 --- a/extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/FallbackVirtualThreadsExecutorService.java +++ b/extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/FallbackVirtualThreadsExecutorService.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import io.smallrye.mutiny.infrastructure.Infrastructure; import io.vertx.core.Vertx; @@ -18,6 +19,8 @@ */ class FallbackVirtualThreadsExecutorService extends AbstractExecutorService { + private AtomicBoolean shutdown = new AtomicBoolean(); + @Override public void execute(Runnable command) { var context = Vertx.currentContext(); @@ -33,26 +36,28 @@ public void execute(Runnable command) { @Override public void shutdown() { - // no-op + shutdown.compareAndSet(false, true); } @Override public List shutdownNow() { + shutdown.compareAndSet(false, true); return Collections.EMPTY_LIST; } @Override public boolean isShutdown() { - return false; + return shutdown.get(); } @Override public boolean isTerminated() { - return false; + return shutdown.get(); } @Override public boolean awaitTermination(long timeout, TimeUnit unit) { - return false; + shutdown.compareAndSet(false, true); + return true; } }