diff --git a/core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java index 71d069f460165..d942f4f11d73d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.deployment.shutdown; +import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -19,4 +20,8 @@ public interface ShutdownBuildTimeConfig { */ @WithDefault("false") boolean delayEnabled(); + + default boolean isDelayEnabled() { + return delayEnabled() && LaunchMode.current() != LaunchMode.DEVELOPMENT; + } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java index af1a0974f7dc4..a2671e717e744 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java @@ -16,6 +16,6 @@ public class ShutdownListenerBuildStep { void setupShutdown(List listeners, ShutdownBuildTimeConfig shutdownBuildTimeConfig, ShutdownRecorder recorder) { recorder.setListeners(listeners.stream().map(ShutdownListenerBuildItem::getShutdownListener).toList(), - shutdownBuildTimeConfig.delayEnabled()); + shutdownBuildTimeConfig.isDelayEnabled()); } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownConfig.java index a438bec701708..f0377ac50d4c3 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownConfig.java @@ -3,6 +3,7 @@ import java.time.Duration; import java.util.Optional; +import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -32,11 +33,13 @@ public interface ShutdownConfig { */ Optional delay(); - default boolean isShutdownTimeoutSet() { - return timeout().isPresent() && timeout().get().toMillis() > 0; + default boolean isTimeoutEnabled() { + return timeout().isPresent() && timeout().get().toMillis() > 0 + && LaunchMode.current() != LaunchMode.DEVELOPMENT; } - default boolean isDelaySet() { - return delay().isPresent() && delay().get().toMillis() > 0; + default boolean isDelayEnabled() { + return delay().isPresent() && delay().get().toMillis() > 0 + && LaunchMode.current() != LaunchMode.DEVELOPMENT; } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownRecorder.java index 236bfa85e8402..8013929baae8b 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownRecorder.java @@ -50,7 +50,7 @@ private static void executePreShutdown() throws InterruptedException { } private static void waitForDelay() { - if (delayEnabled && shutdownConfig.isDelaySet()) { + if (delayEnabled && shutdownConfig.isDelayEnabled()) { try { Thread.sleep(shutdownConfig.delay().get().toMillis()); } catch (InterruptedException e) { @@ -64,7 +64,7 @@ private static void executeShutdown() throws InterruptedException { for (ShutdownListener i : shutdownListeners) { i.shutdown(new LatchShutdownNotification(shutdown)); } - if (shutdownConfig.isShutdownTimeoutSet() + if (shutdownConfig.isTimeoutEnabled() && !shutdown.await(shutdownConfig.timeout().get().toMillis(), TimeUnit.MILLISECONDS)) { log.error("Timed out waiting for graceful shutdown, shutting down anyway."); } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 794c8f15e1aa9..a09cc49a61693 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -475,7 +475,7 @@ public void handle(RoutingContext routingContext) { boolean quarkusWrapperNeeded = false; - if (shutdownConfig.isShutdownTimeoutSet()) { + if (shutdownConfig.isTimeoutEnabled()) { gracefulShutdownFilter.next(root); root = gracefulShutdownFilter; quarkusWrapperNeeded = true;