From 79c2dbad1ceae8534ef351493b4c6ea4900300f4 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Mon, 26 Aug 2019 18:37:36 +1000 Subject: [PATCH] Fixes #3409 The old config provider resolver was not being restored on shutdown, which would cause problems on restarts. --- .../src/main/java/io/quarkus/dev/DevModeMain.java | 9 ++++++--- .../src/main/java/io/quarkus/runtime/Application.java | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java b/core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java index 97da87b9aa33e..f264b68200f6b 100644 --- a/core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java +++ b/core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java @@ -255,9 +255,12 @@ public void stop() { } public void close() { - stop(); - for (HotReplacementSetup i : hotReplacement) { - i.close(); + try { + stop(); + } finally { + for (HotReplacementSetup i : hotReplacement) { + i.close(); + } } } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/Application.java b/core/runtime/src/main/java/io/quarkus/runtime/Application.java index 19da83a928b0a..157e78d1bb013 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/Application.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/Application.java @@ -4,6 +4,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.LockSupport; +import org.eclipse.microprofile.config.spi.ConfigProviderResolver; import org.graalvm.nativeimage.ImageInfo; import org.wildfly.common.Assert; import org.wildfly.common.lock.Locks; @@ -37,6 +38,12 @@ public abstract class Application { private volatile boolean shutdownRequested; private static volatile Application currentApplication; + /** + * The generated config code will install a new resolver, we save the original one here and make sure + * to restore it on shutdown. + */ + private final static ConfigProviderResolver originalResolver = ConfigProviderResolver.instance(); + /** * Construct a new instance. */ @@ -151,6 +158,7 @@ public final void stop() { doStop(); } finally { currentApplication = null; + ConfigProviderResolver.setInstance(originalResolver); stateLock.lock(); try { state = ST_STOPPED;