You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/03/30 12:53:22 UTC

[hbase] branch branch-2.2 updated: HBASE-22101 AsyncAdmin.isTableAvailable should not throw TableNotFoundException

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new d279220  HBASE-22101 AsyncAdmin.isTableAvailable should not throw TableNotFoundException
d279220 is described below

commit d2792200d4d5294c284898a59c01307134864e25
Author: pingsutw <pi...@gmail.com>
AuthorDate: Wed Mar 27 03:17:01 2019 +0800

    HBASE-22101 AsyncAdmin.isTableAvailable should not throw TableNotFoundException
    
    Signed-off-by: zhangduo <zh...@apache.org>
---
 .../java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java    | 6 +++++-
 .../org/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 dd95e1d..0bd8695 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
@@ -700,7 +700,11 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
     CompletableFuture<Boolean> 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 1750926..2c63033 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());
+  }
 }