瀏覽代碼

HADOOP-6213. Remove commons dependency on commons-cli2. Contributed by Amar Kamat.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20@807986 13f79535-47bb-0310-9956-ffa450edef68
Sharad Agarwal 16 年之前
父節點
當前提交
ad10800dea
共有 3 個文件被更改,包括 9 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 二進制
      lib/commons-cli-2.0-SNAPSHOT.jar
  3. 6 5
      src/core/org/apache/hadoop/util/GenericOptionsParser.java

+ 3 - 0
CHANGES.txt

@@ -235,6 +235,9 @@ Release 0.20.1 - Unreleased
     mapred.system.dir in the JobTracker. The JobTracker will bail out if it
     encounters such an exception. (Amar Kamat via ddas)
 
+    HADOOP-6213. Remove commons dependency on commons-cli2. (Amar Kamat via
+    sharad)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

二進制
lib/commons-cli-2.0-SNAPSHOT.jar


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

@@ -205,8 +205,7 @@ public class GenericOptionsParser {
     .withDescription("specify an application configuration file")
     .create("conf");
     Option property = OptionBuilder.withArgName("property=value")
-    .hasArgs()
-    .withArgPattern("=", 1)
+    .hasArg()
     .withDescription("use value for given property")
     .create('D');
     Option libjars = OptionBuilder.withArgName("paths")
@@ -281,9 +280,11 @@ public class GenericOptionsParser {
     }
     if (line.hasOption('D')) {
       String[] property = line.getOptionValues('D');
-      for(int i=0; i<property.length-1; i=i+2) {
-        if (property[i]!=null)
-          conf.set(property[i], property[i+1]);
+      for(String prop : property) {
+        String[] keyval = prop.split("=");
+        if (keyval.length == 2) {
+          conf.set(keyval[0], keyval[1]);
+        }
       }
     }
     conf.setBoolean("mapred.used.genericoptionsparser", true);