Skip to content

Commit

Permalink
Mapping defaults to ConfigSourceContext (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez authored Dec 5, 2023
1 parent 851c35b commit 6d1db48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ public SmallRyeConfig build() {
.forEach(customizer -> customizer.configBuilder(SmallRyeConfigBuilder.this));

ConfigMappingProvider mappingProvider = mappingsBuilder.build();
for (Map.Entry<String, String> entry : mappingProvider.getDefaultValues().entrySet()) {
defaultValues.putIfAbsent(entry.getKey(), entry.getValue());
}
SmallRyeConfig config = new SmallRyeConfig(this);
ConfigMappings.mapConfiguration(config, mappingProvider);
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down

0 comments on commit 6d1db48

Please sign in to comment.