From d776a3caae935f3e08d8a8a5d2ffdaf23cb9b41f Mon Sep 17 00:00:00 2001 From: anoopsamjohn Date: Sun, 30 Jul 2017 15:38:18 +0530 Subject: [PATCH] HBASE-18473 VC.listLabels() erroneously closes any connection. --- .../hbase/security/visibility/VisibilityClient.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java index d99f45429d4..dbcc13f0de0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java @@ -259,9 +259,7 @@ public class VisibilityClient { */ public static ListLabelsResponse listLabels(Connection connection, final String regex) throws Throwable { - Table table = null; - try { - table = connection.getTable(LABELS_TABLE_NAME); + try (Table table = connection.getTable(LABELS_TABLE_NAME)) { Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); @@ -289,14 +287,6 @@ public class VisibilityClient { return result.values().iterator().next(); // There will be exactly one region for labels // table and so one entry in result Map. } - finally { - if (table != null) { - table.close(); - } - if (connection != null) { - connection.close(); - } - } } /**