HBASE-9055 HBaseAdmin#isTableEnabled() should return false for non-existent table (Ted Yu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1507881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-07-29 01:53:50 +00:00
parent bea9384779
commit bc1e374081
2 changed files with 11 additions and 2 deletions

View File

@ -141,7 +141,7 @@ public class ZKTableReadOnly {
throws KeeperException { throws KeeperException {
String znode = ZKUtil.joinZNode(zkw.tableZNode, child); String znode = ZKUtil.joinZNode(zkw.tableZNode, child);
byte [] data = ZKUtil.getData(zkw, znode); byte [] data = ZKUtil.getData(zkw, znode);
if (data == null || data.length <= 0) return ZooKeeperProtos.Table.State.ENABLED; if (data == null || data.length <= 0) return null;
try { try {
ProtobufUtil.expectPBMagicPrefix(data); ProtobufUtil.expectPBMagicPrefix(data);
ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder(); ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();

View File

@ -366,6 +366,15 @@ public class TestAdmin {
assertTrue(exceptionThrown); assertTrue(exceptionThrown);
} }
} }
@Test
public void testIsEnabledOnNonexistentTable() throws IOException {
try {
assertFalse(admin.isTableEnabled(Bytes.toBytes("non-existing")));
} catch (IOException e) {
}
}
/** /**
* Verify schema modification takes. * Verify schema modification takes.
* @throws IOException * @throws IOException