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
This commit is contained in:
parent
ef328827eb
commit
05dd1905a3
|
@ -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)
|
||||
|
|
|
@ -347,9 +347,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
|||
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<Map.Entry<String,String>>,
|
|||
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<Map.Entry<String,String>>,
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -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")) ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue