HADOOP-17130. Configuration.getValByRegex() shouldn't be updating the results while fetching. (#2142)

Contributed by Mukund Thakur

Change-Id: I35fe671d4026e8d3c04fc52012c3edcd4495e14a
This commit is contained in:
Mukund Thakur 2020-07-16 22:39:59 +05:30 committed by Steve Loughran
parent b611559755
commit cb3e378782
1 changed files with 4 additions and 2 deletions

View File

@ -3828,6 +3828,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
Pattern p = Pattern.compile(regex);
Map<String,String> result = new HashMap<String,String>();
List<String> resultKeys = new ArrayList<>();
Matcher m;
for(Map.Entry<Object,Object> item: getProps().entrySet()) {
@ -3835,11 +3836,12 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
item.getValue() instanceof String) {
m = p.matcher((String)item.getKey());
if(m.find()) { // match
result.put((String) item.getKey(),
substituteVars(getProps().getProperty((String) item.getKey())));
resultKeys.add((String) item.getKey());
}
}
}
resultKeys.forEach(item ->
result.put(item, substituteVars(getProps().getProperty(item))));
return result;
}