Skip to content

Commit b21cb91

Browse files
HADOOP-17130. Configuration.getValByRegex() shouldn't be updating the results while fetching. (#2142)
Contributed by Mukund Thakur
1 parent 4083fd5 commit b21cb91

File tree

1 file changed

+4
-2
lines changed
  • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf

1 file changed

+4
-2
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,18 +3869,20 @@ public Map<String,String> getValByRegex(String regex) {
38693869
Pattern p = Pattern.compile(regex);
38703870

38713871
Map<String,String> result = new HashMap<String,String>();
3872+
List<String> resultKeys = new ArrayList<>();
38723873
Matcher m;
38733874

38743875
for(Map.Entry<Object,Object> item: getProps().entrySet()) {
38753876
if (item.getKey() instanceof String &&
38763877
item.getValue() instanceof String) {
38773878
m = p.matcher((String)item.getKey());
38783879
if(m.find()) { // match
3879-
result.put((String) item.getKey(),
3880-
substituteVars(getProps().getProperty((String) item.getKey())));
3880+
resultKeys.add((String) item.getKey());
38813881
}
38823882
}
38833883
}
3884+
resultKeys.forEach(item ->
3885+
result.put(item, substituteVars(getProps().getProperty(item))));
38843886
return result;
38853887
}
38863888

0 commit comments

Comments
 (0)