Skip to content

Commit 187b161

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: Ic0c9c44a1b14b4bfa962cede3f782a98fdfd7513
1 parent 0d88ed2 commit 187b161

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

38673867
Map<String,String> result = new HashMap<String,String>();
3868+
List<String> resultKeys = new ArrayList<>();
38683869
Matcher m;
38693870

38703871
for(Map.Entry<Object,Object> item: getProps().entrySet()) {
38713872
if (item.getKey() instanceof String &&
38723873
item.getValue() instanceof String) {
38733874
m = p.matcher((String)item.getKey());
38743875
if(m.find()) { // match
3875-
result.put((String) item.getKey(),
3876-
substituteVars(getProps().getProperty((String) item.getKey())));
3876+
resultKeys.add((String) item.getKey());
38773877
}
38783878
}
38793879
}
3880+
resultKeys.forEach(item ->
3881+
result.put(item, substituteVars(getProps().getProperty(item))));
38803882
return result;
38813883
}
38823884

0 commit comments

Comments
 (0)