From 90b384564875bb353224630e501772b46d4ca9c5 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 5 May 2015 17:40:31 -0700 Subject: [PATCH] HADOOP-11912. Extra configuration key used in TraceUtils should respect prefix (Masatake Iwasaki via Colin P. McCabe) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/tracing/TraceUtils.java | 12 +++++------- .../org/apache/hadoop/tracing/TestTraceUtils.java | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 9353862c63..adbe8b5673 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -612,6 +612,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 diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java index fa52ac6762..52b5d47316 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java @@ -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); } }; } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/TestTraceUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/TestTraceUtils.java index 80d64b16d3..400d003a2c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/TestTraceUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/TestTraceUtils.java @@ -46,7 +46,7 @@ public void testExtraConfig() { conf.set(TEST_PREFIX + key, oldValue); LinkedList extraConfig = new LinkedList(); - 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)); }