diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index bdfd9cab835..90d35bf6f85 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -725,6 +725,7 @@ public class HBaseAdmin implements Abortable, Closeable { */ public void enableTableAsync(final byte [] tableName) throws IOException { + HTableDescriptor.isLegalTableName(tableName); execute(new MasterCallable() { @Override public Void call() throws ServiceException { @@ -795,6 +796,7 @@ public class HBaseAdmin implements Abortable, Closeable { * @since 0.90.0 */ public void disableTableAsync(final byte [] tableName) throws IOException { + HTableDescriptor.isLegalTableName(tableName); execute(new MasterCallable() { @Override public Void call() throws ServiceException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 8f9eb7dd5a1..24ae44e393c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -1588,6 +1588,21 @@ public class TestAdmin { " HBase was not available"); } + @Test + public void testDisableCatalogTable() throws Exception { + try { + this.admin.disableTable(".META."); + fail("Expected to throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + } + // Before the fix for HBASE-6146, the below table creation was failing as the META table + // actually getting disabled by the disableTable() call. + HTableDescriptor htd = new HTableDescriptor("testDisableCatalogTable".getBytes()); + HColumnDescriptor hcd = new HColumnDescriptor("cf1".getBytes()); + htd.addFamily(hcd); + TEST_UTIL.getHBaseAdmin().createTable(htd); + } + @org.junit.Rule public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu = new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();