From 7c21efdb04528185a96b0b300b1f336c36068856 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 4 Sep 2013 14:58:30 +0000 Subject: [PATCH] HBASE-9421 Provide better error message when dropping non-existent namespace (Ted Yu) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1520043 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/master/TableNamespaceManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java index 6b212651cfd..1a635c8fbb8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.master; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.NavigableSet; @@ -46,9 +47,9 @@ import org.apache.hadoop.hbase.master.handler.CreateTableHandler; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.FSUtils; import com.google.common.collect.Sets; -import org.apache.hadoop.hbase.util.FSUtils; /** * This is a helper class used to manage the namespace @@ -156,7 +157,12 @@ public class TableNamespaceManager { if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) { throw new ConstraintException("Reserved namespace "+name+" cannot be removed."); } - int tableCount = masterServices.listTableDescriptorsByNamespace(name).size(); + int tableCount; + try { + tableCount = masterServices.listTableDescriptorsByNamespace(name).size(); + } catch (FileNotFoundException fnfe) { + throw new ConstraintException("namespace " + name + " does not exist"); + } if (tableCount > 0) { throw new ConstraintException("Only empty namespaces can be removed. " + "Namespace "+name+" has "+tableCount+" tables");