Skip to content

Commit

Permalink
Update bug fix and test to work when there is a non empty prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-grecourt committed Aug 28, 2023
1 parent 5d5b39b commit f6942e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ public ConfigValue<Map<String, String>> asMap() throws MissingValueException {
continue;
}
if (propertyName.startsWith(stringKey + ".")) {
String noPrefix = propertyName.substring(stringPrefix.length());

String noPrefix;
if (stringPrefix.isEmpty()) {
noPrefix = propertyName;
} else {
noPrefix = propertyName.substring(stringPrefix.length() + 1);
}
children.put(noPrefix, delegate.getValue(propertyName, String.class));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ public void testSeConfigAsMap() {
"client.headers.0.name", "foo"
)))
.build();
Map<String, String> map = MpConfig.toHelidonConfig(mpConfig).get("client").asMap().orElse(Map.of());
io.helidon.config.Config seConfig = MpConfig.toHelidonConfig(mpConfig);
Map<String, String> map;

map = seConfig.get("client").asMap().orElse(Map.of());
assertThat(map.get("client.headers.0.name"), is("foo"));

map = seConfig.get("client").detach().asMap().orElse(Map.of());
assertThat(map.get("headers.0.name"), is("foo"));
}

// Github issue #2206
Expand Down

0 comments on commit f6942e8

Please sign in to comment.