hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: HADOOP-11545. ArrayIndexOutOfBoundsException is thrown with "hadoop credential list -provider". Contributed by Brahma Reddy Battula.
Date Wed, 18 Feb 2015 19:19:24 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 f10335b08 -> 5a1531fff


HADOOP-11545. ArrayIndexOutOfBoundsException is thrown with "hadoop credential list -provider".
Contributed by Brahma Reddy Battula.

(cherry picked from commit 17146099197000d85b3aedc84a672111f2c7908a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5a1531ff
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5a1531ff
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5a1531ff

Branch: refs/heads/branch-2
Commit: 5a1531fff6687c4982a206bc4d09f881bfbf4520
Parents: f10335b
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Wed Feb 18 11:17:10 2015 -0800
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Wed Feb 18 11:18:21 2015 -0800

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt  |  3 +++
 .../hadoop/security/alias/CredentialShell.java   | 19 ++++++++++++++++---
 .../hadoop/security/alias/TestCredShell.java     | 15 +++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/5a1531ff/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 6f03cc7..a73a3e9 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -556,6 +556,9 @@ Release 2.7.0 - UNRELEASED
     HADOOP-11599. Client#getTimeout should use IPC_CLIENT_PING_DEFAULT when 
     IPC_CLIENT_PING_KEY is not configured. (zhihai xu via ozawa)
 
+    HADOOP-11545. ArrayIndexOutOfBoundsException is thrown with "hadoop
+    credential list -provider". (Brahma Reddy Battula via aajisaka)
+
 Release 2.6.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5a1531ff/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
index 9311a2d..7a632c1 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
@@ -97,6 +97,10 @@ public class CredentialShell extends Configured implements Tool {
 
     for (int i = 0; i < args.length; i++) { // parse command line
       if (args[i].equals("create")) {
+        if (i == args.length - 1) {
+          printCredShellUsage();
+          return 1;
+        }
         String alias = args[++i];
         command = new CreateCommand(alias);
         if (alias.equals("-help")) {
@@ -104,6 +108,10 @@ public class CredentialShell extends Configured implements Tool {
           return 0;
         }
       } else if (args[i].equals("delete")) {
+        if (i == args.length - 1) {
+          printCredShellUsage();
+          return 1;
+        }
         String alias = args[++i];
         command = new DeleteCommand(alias);
         if (alias.equals("-help")) {
@@ -113,6 +121,10 @@ public class CredentialShell extends Configured implements Tool {
       } else if (args[i].equals("list")) {
         command = new ListCommand();
       } else if (args[i].equals("-provider")) {
+        if (i == args.length - 1) {
+          printCredShellUsage();
+          return 1;
+        }
         userSuppliedProvider = true;
         getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, 
             args[++i]);
@@ -195,7 +207,7 @@ public class CredentialShell extends Configured implements Tool {
   }
 
   private class ListCommand extends Command {
-    public static final String USAGE = "list [-provider] [-help]";
+    public static final String USAGE = "list [-provider provider-path]";
     public static final String DESC =
         "The list subcommand displays the aliases contained within \n" +
         "a particular provider - as configured in core-site.xml or " +
@@ -237,7 +249,7 @@ public class CredentialShell extends Configured implements Tool {
 
   private class DeleteCommand extends Command {
     public static final String USAGE =
-        "delete <alias> [-provider] [-f] [-help]";
+        "delete <alias> [-f] [-provider provider-path]";
     public static final String DESC =
         "The delete subcommand deletes the credential\n" +
         "specified as the <alias> argument from within the provider\n" +
@@ -308,7 +320,8 @@ public class CredentialShell extends Configured implements Tool {
   }
 
   private class CreateCommand extends Command {
-    public static final String USAGE = "create <alias> [-provider] [-help]";
+    public static final String USAGE =
+        "create <alias> [-provider provider-path]";
     public static final String DESC =
         "The create subcommand creates a new credential for the name specified\n" +
         "as the <alias> argument within the provider indicated through\n" +

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5a1531ff/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
index 7ba4bc1..7551df6 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
@@ -212,4 +212,19 @@ public class TestCredShell {
               0, shell.init(new String[] {cmd, "-help"}));
     }
   }
+
+  @Test
+  public void testEmptyArgForCommands() throws Exception {
+    CredentialShell shell = new CredentialShell();
+    String[] command = { "list", "-provider" };
+    assertEquals("Expected empty argument on " + command + " to return 1", 1,
+        shell.init(command));
+
+    for (String cmd : Arrays.asList("create", "delete")) {
+      shell.setConf(new Configuration());
+      assertEquals("Expected empty argument on " + cmd + " to return 1", 1,
+          shell.init(new String[] { cmd }));
+    }
+
+  }
 }


Mime
View raw message