Repository: karaf
Updated Branches:
  refs/heads/master a0d07a32c -> 82af9304b


[KARAF-3403]bin/client Utility Throws ArrayIndexOutOfBoundsException
(cherry picked from commit 86aff6b16af3990251db44bff605682e9d870efa)


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

Branch: refs/heads/master
Commit: 82af9304b62bb1578209ca482cd6ad475c948ddb
Parents: a0d07a3
Author: Freeman Fang <[email protected]>
Authored: Fri Dec 12 10:37:41 2014 +0800
Committer: Freeman Fang <[email protected]>
Committed: Fri Dec 12 10:39:03 2014 +0800

----------------------------------------------------------------------
 .../org/apache/karaf/client/ClientConfig.java   | 49 +++++++++++++++++---
 1 file changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/82af9304/client/src/main/java/org/apache/karaf/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/ClientConfig.java 
b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
index 75539e9..444849d 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -56,23 +56,58 @@ public class ClientConfig {
         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("-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")) {
                     showHelp();
                 } else {

Reply via email to