Repository: hbase Updated Branches: refs/heads/HBASE-7912 c96a263d7 -> 7650f6059
HBASE-16620 Fix backup command-line tool usability issues - addendum 2 fixes potential NPE Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7650f605 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7650f605 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7650f605 Branch: refs/heads/HBASE-7912 Commit: 7650f605905d25c7267259bf89cd236680c049f3 Parents: c96a263 Author: tedyu <yuzhih...@gmail.com> Authored: Wed Sep 14 11:01:15 2016 -0700 Committer: tedyu <yuzhih...@gmail.com> Committed: Wed Sep 14 11:01:15 2016 -0700 ---------------------------------------------------------------------- .../hadoop/hbase/backup/impl/BackupCommands.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/7650f605/hbase-client/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupCommands.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupCommands.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupCommands.java index 31aa348..8f08094 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupCommands.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupCommands.java @@ -161,6 +161,10 @@ public final class BackupCommands { return cmd; } + static int numOfArgs(String[] args) { + if (args == null) return 0; + return args.length; + } public static class CreateCommand extends Command { @@ -583,7 +587,8 @@ public final class BackupCommands { private void processSetDescribe(String[] args) throws IOException { if (args == null || args.length != 3) { - System.err.println("ERROR: Wrong number of args for 'set describe' command: "+args.length); + System.err.println("ERROR: Wrong number of args for 'set describe' command: " + + numOfArgs(args)); printUsage(); System.exit(-1); } @@ -602,7 +607,8 @@ public final class BackupCommands { private void processSetDelete(String[] args) throws IOException { if (args == null || args.length != 3) { - System.err.println("ERROR: Wrong number of args for 'set delete' command: "+args.length); + System.err.println("ERROR: Wrong number of args for 'set delete' command: " + + numOfArgs(args)); printUsage(); System.exit(-1); } @@ -621,7 +627,8 @@ public final class BackupCommands { private void processSetRemove(String[] args) throws IOException { if (args == null || args.length != 4) { - System.err.println("ERROR: Wrong number of args for 'set remove' command: "+args.length); + System.err.println("ERROR: Wrong number of args for 'set remove' command: " + + numOfArgs(args)); printUsage(); System.exit(-1); } @@ -637,7 +644,8 @@ public final class BackupCommands { private void processSetAdd(String[] args) throws IOException { if (args == null || args.length != 4) { - System.err.println("ERROR: Wrong number of args for 'set add' command: "+args.length); + System.err.println("ERROR: Wrong number of args for 'set add' command: " + + numOfArgs(args)); printUsage(); System.exit(-1); }