Repository: quarkusio/quarkus
Issue: Apply default values during property expansion

**Description**
Default values are not applied during expansion of config values. E.g. given a config in _application.properties_ like this:

    quarkus.kafka-streams.application-server=${hostname}:${quarkus.http.port}

Then the HTTP port should default to the value from the config item, but instead an error is raised:

    Build step io.quarkus.deployment.steps.ConfigurationSetup#initializeConfiguration threw an exception: java.util.NoSuchElementException: Property quarkus.http.port not found

Things work when specifying a value explicitly for `quarkus.http.port` or when giving a default value within the expanded expression (${quarkus.http.port:8080}).

CC @dmlloyd 

Changed files:
core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigurationSetup.java
core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
index 2f5df05b613..3923606c59d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
@@ -73,13 +73,19 @@ public class ConfigDefinition extends CompoundConfigType {
     private final TreeMap<String, RootInfo> rootTypesByContainingName = new TreeMap<>();
     private final FieldDescriptor rootField;
     private final TreeMap<String, String> loadedProperties = new TreeMap<>();
+    private final boolean deferResolution;
 
-    public ConfigDefinition(final FieldDescriptor rootField) {
+    public ConfigDefinition(final FieldDescriptor rootField, final boolean deferResolution) {
         super(null, null, false);
+        this.deferResolution = deferResolution;
         Assert.checkNotNullParam("rootField", rootField);
         this.rootField = rootField;
     }
 
+    public ConfigDefinition(final FieldDescriptor rootField) {
+        this(rootField, false);
+    }
+
     void acceptConfigurationValueIntoLeaf(final LeafConfigType leafType, final NameIterator name,
             final ExpandingConfigSource.Cache cache, final SmallRyeConfig config) {
         // primitive/leaf values without a config group
@@ -388,7 +394,16 @@ public static void loadConfiguration(final ExpandingConfigSource.Cache cache, Sm
                             name.goToEnd();
                             leafType.acceptConfigurationValue(name, cache, config);
                             final String nameString = name.toString();
-                            definition.loadedProperties.put(nameString, config.getValue(nameString, String.class));
+                            if (definition.deferResolution) {
+                                boolean old = ExpandingConfigSource.setExpanding(false);
+                                try {
+                                    definition.loadedProperties.put(nameString, config.getValue(nameString, String.class));
+                                } finally {
+                                    ExpandingConfigSource.setExpanding(old);
+                                }
+                            } else {
+                                definition.loadedProperties.put(nameString, config.getValue(nameString, String.class));
+                            }
                             continue outer;
                         }
                     }
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigurationSetup.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigurationSetup.java
index a5d8a9f353a..d75889cef86 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigurationSetup.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigurationSetup.java
@@ -189,7 +189,7 @@ public void initializeConfiguration(
         // set up the configuration definitions
         final ConfigDefinition buildTimeConfig = new ConfigDefinition(FieldDescriptor.of("Bogus", "No field", "Nothing"));
         final ConfigDefinition buildTimeRunTimeConfig = new ConfigDefinition(BUILD_TIME_CONFIG_FIELD);
-        final ConfigDefinition runTimeConfig = new ConfigDefinition(RUN_TIME_CONFIG_FIELD);
+        final ConfigDefinition runTimeConfig = new ConfigDefinition(RUN_TIME_CONFIG_FIELD, true);
 
         // populate it with all known types
         for (Class<?> clazz : ServiceUtil.classesNamedIn(extensionClassLoaderBuildItem.getExtensionClassLoader(),