Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x 4e587e710 -> 3648bc22f


[KARAF-3403]bin/client Utility Throws ArrayIndexOutOfBoundsException


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3648bc22
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3648bc22
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3648bc22

Branch: refs/heads/karaf-2.x
Commit: 3648bc22fc04a35ea3bc950b360951056e649a39
Parents: 4e587e7
Author: Freeman Fang <[email protected]>
Authored: Tue Dec 9 16:06:58 2014 +0800
Committer: Freeman Fang <[email protected]>
Committed: Tue Dec 9 16:06:58 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/karaf/client/Main.java | 56 +++++++++++++++++---
 1 file changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/3648bc22/client/src/main/java/org/apache/karaf/client/Main.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/Main.java 
b/client/src/main/java/org/apache/karaf/client/Main.java
index eba0b99..337e50b 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -84,25 +84,65 @@ public class Main {
         for (int i = 0; i < args.length; i++) {
             if (args[i].charAt(0) == '-') {
                 if (args[i].equals("-a")) {
-                    port = Integer.parseInt(args[++i]);
+                    if (args.length <= ++i) {
+                        System.err.println("miss the port");
+                        System.exit(1);
+                    } else {
+                        port = Integer.parseInt(args[i]);
+                    }
                 } else if (args[i].equals("-h")) {
-                    host = args[++i];
+                    if (args.length <= ++i) {
+                        System.err.println("miss the host");
+                        System.exit(1);
+                    } else {
+                        host = args[i];
+                    }
                 } else if (args[i].equals("-u")) {
-                    user = args[++i];
+                    if (args.length <= ++i) {
+                        System.err.println("miss the user");
+                        System.exit(1);
+                    } else {
+                        user = args[i];
+                    }
                 } else if (args[i].equals("-v")) {
                     level++;
                 } else if (args[i].equals("-r")) {
-                    retryAttempts = Integer.parseInt(args[++i]);
+                    if (args.length <= ++i) {
+                        System.err.println("miss the attempts");
+                        System.exit(1);
+                    } else {
+                        retryAttempts = Integer.parseInt(args[i]);
+                    }
                 } else if (args[i].equals("-p")) {
-                    password = args[++i];
+                    if (args.length <= ++i) {
+                        System.err.println("miss the password");
+                        System.exit(1);
+                    } else {
+                        password = args[i];
+                    }
                 } else if (args[i].equals("-d")) {
-                    retryDelay = Integer.parseInt(args[++i]);
+                    if (args.length <= ++i) {
+                        System.err.println("miss the delay in seconds");
+                        System.exit(1);
+                    } else {
+                        retryDelay = Integer.parseInt(args[i]);
+                    }
                 } else if (args[i].equals("-b")) {
                     batch = true;
                 } else if (args[i].equals("-f")) {
-                    file = args[++i];
+                    if (args.length <= ++i) {
+                        System.err.println("miss the commands file");
+                        System.exit(1);
+                    } else {
+                        file = args[i];
+                    }
                 } else if (args[i].equals("-k")) {
-                    keyFile = args[++i];
+                    if (args.length <= ++i) {
+                        System.err.println("miss the key file");
+                        System.exit(1);
+                    } else {
+                        keyFile = args[i];
+                    }
                 } else if (args[i].equals("--help")) {
                     System.out.println("Apache Karaf client");
                     System.out.println("  -a [port]     specify the port to 
connect to");

Reply via email to