From cb3e3787820fb25dc0412585cf810927731e5bb8 Mon Sep 17 00:00:00 2001 From: Mukund Thakur Date: Thu, 16 Jul 2020 22:39:59 +0530 Subject: [PATCH] HADOOP-17130. Configuration.getValByRegex() shouldn't be updating the results while fetching. (#2142) Contributed by Mukund Thakur Change-Id: I35fe671d4026e8d3c04fc52012c3edcd4495e14a --- .../src/main/java/org/apache/hadoop/conf/Configuration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java index e0111efc25e..5a708a882f6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java @@ -3828,6 +3828,7 @@ public class Configuration implements Iterable>, Pattern p = Pattern.compile(regex); Map result = new HashMap(); + List resultKeys = new ArrayList<>(); Matcher m; for(Map.Entry item: getProps().entrySet()) { @@ -3835,11 +3836,12 @@ public class Configuration implements Iterable>, 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; }