Skip to content

Commit fcf042c

Browse files
authored
Merge pull request #44620 from gsmet/do-not-honor-timeout-in-dev-mode
Do not honor shutdown timeout/delay in dev mode
2 parents d3e99ba + 6ccf8b7 commit fcf042c

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.quarkus.deployment.shutdown;
22

3+
import io.quarkus.runtime.LaunchMode;
34
import io.quarkus.runtime.annotations.ConfigPhase;
45
import io.quarkus.runtime.annotations.ConfigRoot;
56
import io.smallrye.config.ConfigMapping;
@@ -19,4 +20,8 @@ public interface ShutdownBuildTimeConfig {
1920
*/
2021
@WithDefault("false")
2122
boolean delayEnabled();
23+
24+
default boolean isDelayEnabled() {
25+
return delayEnabled() && LaunchMode.current() != LaunchMode.DEVELOPMENT;
26+
}
2227
}

core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class ShutdownListenerBuildStep {
1616
void setupShutdown(List<ShutdownListenerBuildItem> listeners, ShutdownBuildTimeConfig shutdownBuildTimeConfig,
1717
ShutdownRecorder recorder) {
1818
recorder.setListeners(listeners.stream().map(ShutdownListenerBuildItem::getShutdownListener).toList(),
19-
shutdownBuildTimeConfig.delayEnabled());
19+
shutdownBuildTimeConfig.isDelayEnabled());
2020
}
2121
}

core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownConfig.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.time.Duration;
44
import java.util.Optional;
55

6+
import io.quarkus.runtime.LaunchMode;
67
import io.quarkus.runtime.annotations.ConfigPhase;
78
import io.quarkus.runtime.annotations.ConfigRoot;
89
import io.smallrye.config.ConfigMapping;
@@ -32,11 +33,13 @@ public interface ShutdownConfig {
3233
*/
3334
Optional<Duration> delay();
3435

35-
default boolean isShutdownTimeoutSet() {
36-
return timeout().isPresent() && timeout().get().toMillis() > 0;
36+
default boolean isTimeoutEnabled() {
37+
return timeout().isPresent() && timeout().get().toMillis() > 0
38+
&& LaunchMode.current() != LaunchMode.DEVELOPMENT;
3739
}
3840

39-
default boolean isDelaySet() {
40-
return delay().isPresent() && delay().get().toMillis() > 0;
41+
default boolean isDelayEnabled() {
42+
return delay().isPresent() && delay().get().toMillis() > 0
43+
&& LaunchMode.current() != LaunchMode.DEVELOPMENT;
4144
}
4245
}

core/runtime/src/main/java/io/quarkus/runtime/shutdown/ShutdownRecorder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private static void executePreShutdown() throws InterruptedException {
5050
}
5151

5252
private static void waitForDelay() {
53-
if (delayEnabled && shutdownConfig.isDelaySet()) {
53+
if (delayEnabled && shutdownConfig.isDelayEnabled()) {
5454
try {
5555
Thread.sleep(shutdownConfig.delay().get().toMillis());
5656
} catch (InterruptedException e) {
@@ -64,7 +64,7 @@ private static void executeShutdown() throws InterruptedException {
6464
for (ShutdownListener i : shutdownListeners) {
6565
i.shutdown(new LatchShutdownNotification(shutdown));
6666
}
67-
if (shutdownConfig.isShutdownTimeoutSet()
67+
if (shutdownConfig.isTimeoutEnabled()
6868
&& !shutdown.await(shutdownConfig.timeout().get().toMillis(), TimeUnit.MILLISECONDS)) {
6969
log.error("Timed out waiting for graceful shutdown, shutting down anyway.");
7070
}

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public void handle(RoutingContext routingContext) {
475475

476476
boolean quarkusWrapperNeeded = false;
477477

478-
if (shutdownConfig.isShutdownTimeoutSet()) {
478+
if (shutdownConfig.isTimeoutEnabled()) {
479479
gracefulShutdownFilter.next(root);
480480
root = gracefulShutdownFilter;
481481
quarkusWrapperNeeded = true;

0 commit comments

Comments
 (0)