ACCUMULO-3589 Check tables for existence at end of shell command.

We were checking tables provided to the DUCommand to early which
caused us to miss the existence check on some of the ways that
users can specify tables.

Signed-off-by: Josh Elser <els...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2b168f81
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2b168f81
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2b168f81

Branch: refs/heads/master
Commit: 2b168f819f8dfa865785fd644e6bfa82722ff4d0
Parents: a506c0b
Author: Tristen Georgiou <tristen.georg...@gmail.com>
Authored: Mon May 4 13:50:42 2015 -0400
Committer: Josh Elser <els...@apache.org>
Committed: Mon May 4 13:53:04 2015 -0400

----------------------------------------------------------------------
 .../accumulo/core/util/shell/commands/DUCommand.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b168f81/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
 
b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
index 5c0a486..d0ee908 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
@@ -44,11 +44,7 @@ public class DUCommand extends Command {
     final SortedSet<String> tables = new 
TreeSet<String>(Arrays.asList(cl.getArgs()));
 
     if (cl.hasOption(Shell.tableOption)) {
-      String tableName = cl.getOptionValue(Shell.tableOption);
-      if (!shellState.getConnector().tableOperations().exists(tableName)) {
-        throw new TableNotFoundException(tableName, tableName, "specified 
table that doesn't exist");
-      }
-      tables.add(tableName);
+      tables.add(cl.getOptionValue(Shell.tableOption));
     }
 
     if (cl.hasOption(optNamespace.getOpt())) {
@@ -73,6 +69,13 @@ public class DUCommand extends Command {
       tables.add(shellState.getTableName());
     }
 
+    // sanity check...make sure the user-specified tables exist
+    for (String tableName : tables) {
+      if (!shellState.getConnector().tableOperations().exists(tableName)) {
+        throw new TableNotFoundException(tableName, tableName, "specified 
table that doesn't exist");
+      }
+    }
+
     try {
       String valueFormat = prettyPrint ? "%9s" : "%,24d";
       for (DiskUsage usage : 
shellState.getConnector().tableOperations().getDiskUsage(tables)) {

Reply via email to