Repository: quarkusio/quarkus
Issue: Build failure on hot reload [Development environment]

**Bug Description**
In the application.properties, I'm using the wildcard to config database user, password, url... for 2 environments (dev, prod)
examples:

- %dev.quarkus.datasource.password=xxxxxxxx

- %prod.quarkus.datasource.password=xxxxxxxx

In the development environment using `mvnw compile quarkus:dev:` the first build is ok, work's fine .
But, when i change any class and try to send a request, the hot reload throws an Exception:

`2019-08-02 11:37:49,564 ERROR [io.qua.dev.DevModeMain] (executor-thread-12) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.steps.ConfigurationSetup#initializeConfiguration threw an exception: java.util.NoSuchElementException: Property quarkus.datasource.password not found
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:141)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:171)
	at io.quarkus.dev.DevModeMain.restartApp(DevModeMain.java:198)
	at io.quarkus.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:109)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup.handleHotDeploymentRequest(UndertowHotReplacementSetup.java:67)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup$1$1.handleRequest(UndertowHotReplacementSetup.java:56)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
	at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at java.lang.Thread.run(Thread.java:745)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.steps.ConfigurationSetup#initializeConfiguration threw an exception: java.util.NoSuchElementException: Property quarkus.datasource.password not found
	at io.quarkus.builder.Execution.run(Execution.java:108)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:121)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:115)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:107)
	... 18 more
Caused by: java.util.NoSuchElementException: Property quarkus.datasource.password not found
	at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:89)
	at io.quarkus.deployment.steps.ConfigurationSetup.initializeConfiguration(ConfigurationSetup.java:225)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:768)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
	at io.quarkus.builder.BuildContext$$Lambda$116/2101929518.run(Unknown Source)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	... 2 more`

**To Reproduce**
Steps to reproduce the behavior:
1. Make database configuration for dev and prod in application.properties
2. Start api in dev mode `mvnw compile quarkus:dev:`
3. Change any class in project to make a hot reload
4. Make a request and take a look on log

**Configuration**
```properties
# %dev.quarkus.datasource.password=xxxxxxxx

# %prod.quarkus.datasource.password=xxxxxxxx

```
**Environment **
 - Quarkus version or git rev: 0.20.0

My question is:
This is a bug or any new configuration needed ?


Changed files:
core/runtime/src/main/java/io/quarkus/runtime/Application.java, core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java

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 97da87b9aa3..f264b68200f 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 19da83a928b..157e78d1bb0 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;