From 0c882100d4dccd50d52e9e91bc67fdcc35578f93 Mon Sep 17 00:00:00 2001 From: pingsutw Date: Wed, 27 Mar 2019 03:17:01 +0800 Subject: [PATCH] HBASE-22101 AsyncAdmin.isTableAvailable should not throw TableNotFoundException Signed-off-by: zhangduo --- .../org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java | 6 +++++- .../apache/hadoop/hbase/client/TestAsyncTableAdminApi.java | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java index e6bc9187af6..38781e14d56 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java @@ -647,7 +647,11 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { CompletableFuture future = new CompletableFuture<>(); addListener(isTableEnabled(tableName), (enabled, error) -> { if (error != null) { - future.completeExceptionally(error); + if (error instanceof TableNotFoundException) { + future.complete(false); + } else { + future.completeExceptionally(error); + } return; } if (!enabled) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java index 1750926785b..2c63033daa0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java @@ -453,4 +453,11 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase { assertTrue(e.getCause() instanceof TableExistsException); } } + + @Test + public void testIsTableAvailableWithInexistantTable() throws Exception { + final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new"); + // test for inexistant table + assertFalse(admin.isTableAvailable(newTableName).get()); + } }