From e28947c42886e3b7c359b299fc612c14e420ee5e Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Thu, 14 Nov 2013 17:49:33 +0000 Subject: [PATCH] HADOOP-10094. Merging change r1541991 from trunk to branch-2. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1541993 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/util/GenericOptionsParser.java | 3 +++ .../org/apache/hadoop/util/TestGenericOptionsParser.java | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 16926828c31..d25c4f1c2c2 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -143,6 +143,9 @@ Release 2.3.0 - UNRELEASED HADOOP-10093. hadoop-env.cmd sets HADOOP_CLIENT_OPTS with a max heap size that is too small. (Shanyu Zhao via cnauroth) + HADOOP-10094. NPE in GenericOptionsParser#preProcessForWindows(). + (Enis Soztutar via cnauroth) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java index 6048f8e8185..67818555393 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java @@ -431,6 +431,9 @@ public class GenericOptionsParser { if (!Shell.WINDOWS) { return args; } + if (args == null) { + return null; + } List newArgs = new ArrayList(args.length); for (int i=0; i < args.length; i++) { String prop = null; diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java index 87bc83b4192..48a419b3a52 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java @@ -282,4 +282,12 @@ public class TestGenericOptionsParser extends TestCase { Arrays.toString(remainingArgs) + Arrays.toString(expectedRemainingArgs), expectedRemainingArgs, remainingArgs); } + + /** Test passing null as args. Some classes still call + * Tool interface from java passing null. + */ + public void testNullArgs() throws IOException { + GenericOptionsParser parser = new GenericOptionsParser(conf, null); + parser.getRemainingArgs(); + } }