Browse Source

svn merge -c 1301551 from trunk to branch-0.23 FIXES MAPREDUCE-4010. TestWritableJobConf fails on trunk (tucu via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1301553 13f79535-47bb-0310-9956-ffa450edef68
Robert Joseph Evans 13 years ago
parent
commit
4c0306714b

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java

@@ -303,7 +303,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
    * @return <code>true</code> if the key is deprecated and 
    * @return <code>true</code> if the key is deprecated and 
    *         <code>false</code> otherwise.
    *         <code>false</code> otherwise.
    */
    */
-  private static boolean isDeprecated(String key) {
+  public static boolean isDeprecated(String key) {
     return deprecatedKeyMap.containsKey(key);
     return deprecatedKeyMap.containsKey(key);
   }
   }
 
 

+ 2 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -72,6 +72,8 @@ Release 0.23.3 - UNRELEASED
 
 
     MAPREDUCE-3431 NPE in Resource Manager shutdown. (stevel)
     MAPREDUCE-3431 NPE in Resource Manager shutdown. (stevel)
 
 
+    MAPREDUCE-4010.  TestWritableJobConf fails on trunk (tucu via bobby)
+
 Release 0.23.2 - UNRELEASED
 Release 0.23.2 - UNRELEASED
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 10 - 5
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestWritableJobConf.java

@@ -57,20 +57,25 @@ public class TestWritableJobConf extends TestCase {
   }
   }
 
 
   private void assertEquals(Configuration conf1, Configuration conf2) {
   private void assertEquals(Configuration conf1, Configuration conf2) {
-    assertEquals(conf1.size(), conf2.size());
-
+    // We ignore deprecated keys because after deserializing, both the
+    // deprecated and the non-deprecated versions of a config are set.
+    // This is consistent with both the set and the get methods.
     Iterator<Map.Entry<String, String>> iterator1 = conf1.iterator();
     Iterator<Map.Entry<String, String>> iterator1 = conf1.iterator();
     Map<String, String> map1 = new HashMap<String,String>();
     Map<String, String> map1 = new HashMap<String,String>();
     while (iterator1.hasNext()) {
     while (iterator1.hasNext()) {
       Map.Entry<String, String> entry = iterator1.next();
       Map.Entry<String, String> entry = iterator1.next();
-      map1.put(entry.getKey(), entry.getValue());
+      if (!Configuration.isDeprecated(entry.getKey())) {
+        map1.put(entry.getKey(), entry.getValue());
+      }
     }
     }
 
 
-    Iterator<Map.Entry<String, String>> iterator2 = conf1.iterator();
+    Iterator<Map.Entry<String, String>> iterator2 = conf2.iterator();
     Map<String, String> map2 = new HashMap<String,String>();
     Map<String, String> map2 = new HashMap<String,String>();
     while (iterator2.hasNext()) {
     while (iterator2.hasNext()) {
       Map.Entry<String, String> entry = iterator2.next();
       Map.Entry<String, String> entry = iterator2.next();
-      map2.put(entry.getKey(), entry.getValue());
+      if (!Configuration.isDeprecated(entry.getKey())) {
+        map2.put(entry.getKey(), entry.getValue());
+      }
     }
     }
 
 
     assertEquals(map1, map2);
     assertEquals(map1, map2);