From 05dd1905a305ef017cb2a870d9e35c2c5f329494 Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Thu, 22 Mar 2012 16:49:24 +0000 Subject: [PATCH] Merge -r 1303883:1303884 from trunk to branch. FIXES: HADOOP-8197 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1303886 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 2 ++ .../org/apache/hadoop/conf/Configuration.java | 19 ++++++++----------- .../hadoop/conf/TestDeprecatedKeys.java | 1 + 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 3571880c050..f23353b0ebd 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -152,6 +152,8 @@ Release 0.23.3 - UNRELEASED HADOOP-8157. Fix race condition in Configuration that could cause spurious ClassNotFoundExceptions after a GC. (todd) + HADOOP-8197. Configuration logs WARNs on every use of a deprecated key (tucu) + BREAKDOWN OF HADOOP-7454 SUBTASKS HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh) 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 9e1ce260624..a9e7c0b94a6 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 @@ -347,9 +347,7 @@ public class Configuration implements Iterable>, private String handleDeprecation(String name) { if (isDeprecated(name)) { DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name); - if (!keyInfo.accessed) { - LOG.warn(keyInfo.getWarningMessage(name)); - } + warnOnceIfDeprecated(name); for (String newKey : keyInfo.newKeys) { if(newKey != null) { name = newKey; @@ -362,11 +360,6 @@ public class Configuration implements Iterable>, getOverlay().containsKey(deprecatedKey)) { getProps().setProperty(name, getOverlay().getProperty(deprecatedKey)); getOverlay().setProperty(name, getOverlay().getProperty(deprecatedKey)); - - DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(deprecatedKey); - if (!keyInfo.accessed) { - LOG.warn(keyInfo.getWarningMessage(deprecatedKey)); - } } return name; } @@ -662,12 +655,16 @@ public class Configuration implements Iterable>, getOverlay().setProperty(altName, value); getProps().setProperty(altName, value); } - if (isDeprecated(name)) { - DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name); + warnOnceIfDeprecated(name); + } + + private void warnOnceIfDeprecated(String name) { + DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name); + if (keyInfo != null && !keyInfo.accessed) { LOG.warn(keyInfo.getWarningMessage(name)); } } - + /** * Unset a previously set property. */ diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java index 8631771b9df..584b3372b89 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java @@ -31,6 +31,7 @@ public class TestDeprecatedKeys extends TestCase { public void testDeprecatedKeys() throws Exception { Configuration conf = new Configuration(); conf.set("topology.script.file.name", "xyz"); + conf.set("topology.script.file.name", "xyz"); String scriptFile = conf.get(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY); assertTrue(scriptFile.equals("xyz")) ; }