Skip to content

Commit ebf333b

Browse files
committed
fix: null matches with exist should work
1 parent 2f93fad commit ebf333b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,15 @@ private static boolean doesRuleMatch(Rule rule) {
106106
private static boolean matchOperator(String value, String operator, List<String> matches) {
107107
// not sure if these are nullable, but the semantics make sense
108108
// and that will save us from a NPE
109-
if (value == null || matches == null || operator == null) {
109+
if (value == null || operator == null) {
110110
return false;
111111
}
112112
if (operator == "exists") {
113113
return true;
114114
}
115+
if (matches == null) {
116+
return false;
117+
}
115118
value = value.toLowerCase();
116119
for (String match : matches) {
117120
if (match == null) {
@@ -148,11 +151,11 @@ static boolean selectorMatch(String origin, List<String> matches, String operato
148151
if (key == null) {
149152
return false;
150153
}
151-
String value = System.getenv(key.toUpperCase());
152-
if (value == null) {
154+
String envValue = System.getenv(key.toUpperCase());
155+
if (envValue == null) {
153156
return false;
154157
}
155-
return matchOperator(value, operator, matches);
158+
return matchOperator(envValue, operator, matches);
156159
case "process_arguments":
157160
if (key == null) {
158161
return false;
@@ -164,8 +167,8 @@ static boolean selectorMatch(String origin, List<String> matches, String operato
164167
key);
165168
return false;
166169
}
167-
value = System.getProperty(key.substring(2));
168-
return matchOperator(value, operator, matches);
170+
String argValue = System.getProperty(key.substring(2));
171+
return matchOperator(argValue, operator, matches);
169172
case "tags":
170173
// TODO: Support this down the line (Must define the source of "tags" first)
171174
return false;

0 commit comments

Comments
 (0)