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(); - } - } } /**