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/trunk@808415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sharad Agarwal 2009-08-27 13:55:19 +00:00
parent 8621b830f8
commit aa10f303e3
3 changed files with 10 additions and 1 deletions

View File

@ -944,6 +944,9 @@ Trunk (unreleased changes)
HADOOP-6152. Fix classpath variables in bin/hadoop-config.sh and some
other scripts. (Aaron Kimball via szetszwo)
HADOOP-6215. fix GenericOptionParser to deal with -D with '=' in the
value. (Amar Kamat via sharad)
Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -281,7 +281,7 @@ private void processGeneralOptions(Configuration conf,
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]);
}

View File

@ -103,6 +103,12 @@ public void testGenericOptionsParser() throws Exception {
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() {