HADOOP-11912. Extra configuration key used in TraceUtils should respect prefix (Masatake Iwasaki via Colin P. McCabe)

(cherry picked from commit 90b3845648)
This commit is contained in:
Colin Patrick Mccabe 2015-05-05 17:40:31 -07:00
parent b8e4507637
commit 606e4f4940
3 changed files with 9 additions and 8 deletions

View File

@ -162,6 +162,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-11926. test-patch.sh mv does wrong math (aw)
HADOOP-11912. Extra configuration key used in TraceUtils should respect
prefix (Masatake Iwasaki via Colin P. McCabe)
Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -47,18 +47,16 @@ public static HTraceConfiguration wrapHadoopConf(final String prefix,
return new HTraceConfiguration() {
@Override
public String get(String key) {
if (extraMap.containsKey(key)) {
return extraMap.get(key);
}
return conf.get(prefix + key, "");
return get(key, "");
}
@Override
public String get(String key, String defaultValue) {
if (extraMap.containsKey(key)) {
return extraMap.get(key);
String prefixedKey = prefix + key;
if (extraMap.containsKey(prefixedKey)) {
return extraMap.get(prefixedKey);
}
return conf.get(prefix + key, defaultValue);
return conf.get(prefixedKey, defaultValue);
}
};
}

View File

@ -46,7 +46,7 @@ public void testExtraConfig() {
conf.set(TEST_PREFIX + key, oldValue);
LinkedList<ConfigurationPair> extraConfig =
new LinkedList<ConfigurationPair>();
extraConfig.add(new ConfigurationPair(key, newValue));
extraConfig.add(new ConfigurationPair(TEST_PREFIX + key, newValue));
HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf, extraConfig);
assertEquals(newValue, wrapped.get(key));
}