Skip to content

Commit

Permalink
Do not match prefix Env if exists (#1327)
Browse files Browse the repository at this point in the history
(cherry picked from commit fd12b46)
  • Loading branch information
radcortez committed Feb 24, 2025
1 parent c5e6bf7 commit 91fd5be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static String toLowerCaseAndDotted(final String name) {
*/
public static boolean isInPath(final String path, final String name) {
if (name.equals(path)) {
return true;
return false;
}

// if property is less than the root no way to match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,19 @@ interface ServiceDiscoveryConfiguration {
}
}

@Test
void prefixAsEnv() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
.withSources(new EnvConfigSource(Map.of("PREFIX", "VALUE", "PREFIX_VALUE", "VALUE"), 300))
.withMapping(PrefixAsEnv.class)
.build();
}

@ConfigMapping(prefix = "prefix")
interface PrefixAsEnv {
Optional<String> value();
}

private static boolean envSourceEquals(String name, String lookup) {
return BOOLEAN_CONVERTER.convert(new EnvConfigSource(Map.of(name, "true"), 100).getValue(lookup));
}
Expand Down

0 comments on commit 91fd5be

Please sign in to comment.