Skip to content

Commit 0ea5afb

Browse files
committed
fix getString logic to use the first found value
1 parent a31cb1b commit 0ea5afb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,22 @@ public <T extends Enum<T>> T getEnum(String key, Class<T> enumType, T defaultVal
7474
}
7575

7676
public String getString(String key, String defaultValue, String... aliases) {
77-
String value = null;
77+
String foundValue = null;
7878
for (ConfigProvider.Source source : sources) {
79-
value = source.get(key, aliases);
80-
if (value != null && collectConfig) {
81-
ConfigCollector.get().put(key, value, source.origin());
79+
String value = source.get(key, aliases);
80+
if (value != null) {
81+
if (collectConfig) {
82+
ConfigCollector.get().put(key, value, source.origin());
83+
}
84+
if (foundValue == null) {
85+
foundValue = value;
86+
}
8287
}
8388
}
8489
if (collectConfig) {
8590
ConfigCollector.get().put(key, defaultValue, ConfigOrigin.DEFAULT);
8691
}
87-
if (value != null) {
88-
return value;
89-
}
90-
return defaultValue;
92+
return foundValue != null ? foundValue : defaultValue;
9193
}
9294

9395
/**

0 commit comments

Comments
 (0)