Author: yhemanth
Date: Tue Sep 8 10:56:15 2009
New Revision: 812455
URL: http://svn.apache.org/viewvc?rev=812455&view=rev
Log:
HADOOP-6243. Fix a NullPointerException in processing deprecated keys.
Contributed by Sreekanth Ramakrishnan.
Modified:
hadoop/common/trunk/CHANGES.txt
hadoop/common/trunk/src/java/core-default.xml
hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfigurationDeprecation.java
Modified: hadoop/common/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=812455&r1=812454&r2=812455&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Sep 8 10:56:15 2009
@@ -984,6 +984,9 @@
HADOOP-6229. Attempt to make a directory under an existing file on
LocalFileSystem should throw an Exception. (Boris Shkolnik via tomwhite)
+ HADOOP-6243. Fix a NullPointerException in processing deprecated keys.
+ (Sreekanth Ramakrishnan via yhemanth)
+
Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES
Modified: hadoop/common/trunk/src/java/core-default.xml
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/core-default.xml?rev=812455&r1=812454&r2=812455&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/core-default.xml (original)
+++ hadoop/common/trunk/src/java/core-default.xml Tue Sep 8 10:56:15 2009
@@ -485,11 +485,4 @@
IP address.
</description>
</property>
-
-<property>
- <name>hadoop.conf.extra.classes</name>
- <value>org.apache.hadoop.mapred.JobConf</value>
- <final>true</final>
-</property>
-
</configuration>
Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=812455&r1=812454&r2=812455&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
(original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Tue
Sep 8 10:56:15 2009
@@ -336,6 +336,12 @@
}
addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");
+ //Add code for managing deprecated key mapping
+ //for example
+ //addDeprecation("oldKey1",new String[]{"newkey1","newkey2"});
+ //adds deprecation for oldKey1 to two new keys(newkey1, newkey2).
+ //so get or set of oldKey1 will correctly populate/access values of
+ //newkey1 and newkey2
}
private Properties properties;
@@ -1364,56 +1370,8 @@
loadResource(properties, resource, quiet);
}
// process for deprecation.
- processDeprecation();
- }
-
- /**
- * Flag to ensure that the classes mentioned in the value of the property
- * <code>hadoop.conf.extra.classes</code> are loaded only once for
- * all instances of <code>Configuration</code>
- */
- private static AtomicBoolean loadedDeprecation = new AtomicBoolean(false);
-
- private static final String extraConfKey = "hadoop.conf.extra.classes";
-
- /**
- * adds all the deprecations to the deprecatedKeyMap and updates the values
of
- * the appropriate keys
- */
- private void processDeprecation() {
- populateDeprecationMapping();
processDeprecatedKeys();
}
-
- /**
- * Loads all the classes in mapred and hdfs that extend Configuration and
that
- * have deprecations to be added into deprecatedKeyMap
- */
- private synchronized void populateDeprecationMapping() {
- if (!loadedDeprecation.get()) {
- // load classes from mapred and hdfs which extend Configuration and have
- // deprecations added in their static blocks
- String classnames = substituteVars(properties.getProperty(extraConfKey));
- if (classnames == null) {
- return;
- }
- String[] classes = StringUtils.getStrings(classnames);
- for (String className : classes) {
- try {
- Class.forName(className);
- } catch (ClassNotFoundException e) {
- LOG.warn(className + " is not in the classpath");
- }
- }
- // make deprecatedKeyMap unmodifiable in order to prevent changes to
- // it in user's code.
- deprecatedKeyMap = Collections.unmodifiableMap(deprecatedKeyMap);
- // ensure that deprecation processing is done only once for all
- // instances of this object
- loadedDeprecation.set(true);
- }
- }
-
/**
* Updates the keys that are replacing the deprecated keys and removes the
* deprecated keys from memory.
Modified:
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfigurationDeprecation.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfigurationDeprecation.java?rev=812455&r1=812454&r2=812455&view=diff
==============================================================================
---
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfigurationDeprecation.java
(original)
+++
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfigurationDeprecation.java
Tue Sep 8 10:56:15 2009
@@ -81,30 +81,27 @@
out.write("</property>\n");
}
- static class MyConf extends Configuration {
- static {
- // add deprecation mappings.
- Configuration.addDeprecation("old.key1", new String[]{"new.key1"});
- Configuration.addDeprecation("old.key2", new String[]{"new.key2"});
- Configuration.addDeprecation("old.key3", new String[]{"new.key3"});
- Configuration.addDeprecation("old.key4", new String[]{"new.key4"});
- Configuration.addDeprecation("old.key5", new String[]{"new.key5"});
- Configuration.addDeprecation("old.key6", new String[]{"new.key6"});
- Configuration.addDeprecation("old.key7", new String[]{"new.key7"});
- Configuration.addDeprecation("old.key8", new String[]{"new.key8"});
- Configuration.addDeprecation("old.key9", new String[]{"new.key9"});
- Configuration.addDeprecation("old.key10", new String[]{"new.key10"});
- Configuration.addDeprecation("old.key11", new String[]{"new.key11"});
- Configuration.addDeprecation("old.key12", new String[]{"new.key12"});
- Configuration.addDeprecation("old.key13", new String[]{"new.key13"});
- Configuration.addDeprecation("old.key14", new String[]{"new.key14"});
- Configuration.addDeprecation("old.key15", new String[]{"new.key15"});
- Configuration.addDeprecation("old.key16", new String[]{"new.key16"});
- Configuration.addDeprecation("A", new String[]{"B"});
- Configuration.addDeprecation("C", new String[]{"D"});
- Configuration.addDeprecation("E", new String[]{"F"});
- Configuration.addDeprecation("G", new String[]{"H","I"});
- }
+ private void addDeprecationToConfiguration() {
+ Configuration.addDeprecation("old.key1", new String[]{"new.key1"});
+ Configuration.addDeprecation("old.key2", new String[]{"new.key2"});
+ Configuration.addDeprecation("old.key3", new String[]{"new.key3"});
+ Configuration.addDeprecation("old.key4", new String[]{"new.key4"});
+ Configuration.addDeprecation("old.key5", new String[]{"new.key5"});
+ Configuration.addDeprecation("old.key6", new String[]{"new.key6"});
+ Configuration.addDeprecation("old.key7", new String[]{"new.key7"});
+ Configuration.addDeprecation("old.key8", new String[]{"new.key8"});
+ Configuration.addDeprecation("old.key9", new String[]{"new.key9"});
+ Configuration.addDeprecation("old.key10", new String[]{"new.key10"});
+ Configuration.addDeprecation("old.key11", new String[]{"new.key11"});
+ Configuration.addDeprecation("old.key12", new String[]{"new.key12"});
+ Configuration.addDeprecation("old.key13", new String[]{"new.key13"});
+ Configuration.addDeprecation("old.key14", new String[]{"new.key14"});
+ Configuration.addDeprecation("old.key15", new String[]{"new.key15"});
+ Configuration.addDeprecation("old.key16", new String[]{"new.key16"});
+ Configuration.addDeprecation("A", new String[]{"B"});
+ Configuration.addDeprecation("C", new String[]{"D"});
+ Configuration.addDeprecation("E", new String[]{"F"});
+ Configuration.addDeprecation("G", new String[]{"H","I"});
}
/**
@@ -123,8 +120,6 @@
public void testDeprecation() throws IOException {
out=new BufferedWriter(new FileWriter(CONFIG));
startConfig();
- appendProperty("hadoop.conf.extra.classes", MyConf.class.getName()
- + ",myconf1");
// load keys with default values. Some of them are set to final to
// test the precedence order between deprecation and being final
appendProperty("new.key1","default.value1",true);
@@ -145,6 +140,7 @@
appendProperty("new.key16","default.value16");
endConfig();
Path fileResource = new Path(CONFIG);
+ addDeprecationToConfiguration();
conf.addResource(fileResource);
out=new BufferedWriter(new FileWriter(CONFIG2));