Skip to content

Commit 28db29d

Browse files
mukund-thakursteveloughran
authored andcommitted
HADOOP-17130. Configuration.getValByRegex() shouldn't be updating the results while fetching. (#2142)
Contributed by Mukund Thakur Change-Id: I35fe671d4026e8d3c04fc52012c3edcd4495e14a
1 parent 4163b43 commit 28db29d

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
@@ -3839,18 +3839,20 @@ public Map<String,String> getValByRegex(String regex) {
38393839
Pattern p = Pattern.compile(regex);
38403840

38413841
Map<String,String> result = new HashMap<String,String>();
3842+
List<String> resultKeys = new ArrayList<>();
38423843
Matcher m;
38433844

38443845
for(Map.Entry<Object,Object> item: getProps().entrySet()) {
38453846
if (item.getKey() instanceof String &&
38463847
item.getValue() instanceof String) {
38473848
m = p.matcher((String)item.getKey());
38483849
if(m.find()) { // match
3849-
result.put((String) item.getKey(),
3850-
substituteVars(getProps().getProperty((String) item.getKey())));
3850+
resultKeys.add((String) item.getKey());
38513851
}
38523852
}
38533853
}
3854+
resultKeys.forEach(item ->
3855+
result.put(item, substituteVars(getProps().getProperty(item))));
38543856
return result;
38553857
}
38563858

0 commit comments

Comments
 (0)