瀏覽代碼

HADOOP-6215. fix GenericOptionParser to deal with -D with '=' in the value. Contributed by Amar Kamat.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20@808414 13f79535-47bb-0310-9956-ffa450edef68
Sharad Agarwal 16 年之前
父節點
當前提交
38930f2295

+ 3 - 0
CHANGES.txt

@@ -241,6 +241,9 @@ Release 0.20.1 - Unreleased
     MAPREDUCE-430. Fix a bug related to task getting stuck in case of 
     OOM error. (Amar Kamat via ddas)
 
+    HADOOP-6215. fix GenericOptionParser to deal with -D with '=' in the 
+    value. (Amar Kamat via sharad)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

+ 1 - 1
src/core/org/apache/hadoop/util/GenericOptionsParser.java

@@ -281,7 +281,7 @@ public class GenericOptionsParser {
     if (line.hasOption('D')) {
       String[] property = line.getOptionValues('D');
       for(String prop : property) {
-        String[] keyval = prop.split("=");
+        String[] keyval = prop.split("=", 2);
         if (keyval.length == 2) {
           conf.set(keyval[0], keyval[1]);
         }

+ 6 - 0
src/test/org/apache/hadoop/util/TestGenericsUtil.java

@@ -103,6 +103,12 @@ public class TestGenericsUtil extends TestCase {
      GenericOptionsParser parser = new GenericOptionsParser(
         new Configuration(), new String[] {"-jt"});
     assertEquals(parser.getRemainingArgs().length, 0);
+    
+    // test if -D accepts -Dx=y=z
+    parser = 
+      new GenericOptionsParser(new Configuration(), 
+                               new String[] {"-Dx=y=z"});
+    assertEquals(parser.getConfiguration().get("x"), "y=z");
   }
   
   public void testGetClass() {