diff --git a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java index 3dea990b0..e4f30ad65 100644 --- a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java +++ b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java @@ -697,6 +697,9 @@ public SmallRyeConfig build() { .forEach(customizer -> customizer.configBuilder(SmallRyeConfigBuilder.this)); ConfigMappingProvider mappingProvider = mappingsBuilder.build(); + for (Map.Entry entry : mappingProvider.getDefaultValues().entrySet()) { + defaultValues.putIfAbsent(entry.getKey(), entry.getValue()); + } SmallRyeConfig config = new SmallRyeConfig(this); ConfigMappings.mapConfiguration(config, mappingProvider); return config; diff --git a/implementation/src/test/java/io/smallrye/config/ConfigSourceFactoryTest.java b/implementation/src/test/java/io/smallrye/config/ConfigSourceFactoryTest.java index 46e7fd2ef..8eb0b96df 100644 --- a/implementation/src/test/java/io/smallrye/config/ConfigSourceFactoryTest.java +++ b/implementation/src/test/java/io/smallrye/config/ConfigSourceFactoryTest.java @@ -48,10 +48,11 @@ void expression() { SmallRyeConfig config = new SmallRyeConfigBuilder() .addDefaultInterceptors() .withSources(new ExpressionConfigSourceFactory()) - .withSources(config("expression.value", "12${DEFAULT:}")) - .withSources(new EnvConfigSource(Map.of("DEFAULT", "34"), 100)) + .withSources(new EnvConfigSource(Map.of("DEFAULT", "1234"), 100)) + .withMapping(Expression.class) .build(); + assertEquals("1234", config.getConfigMapping(Expression.class).value()); assertEquals("1234", config.getRawValue("factory.expression")); }