diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index e59969ac97b..c73d8a3ba82 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -2722,11 +2722,21 @@ public class HBaseFsck extends Configured { HTableDescriptor[] getHTableDescriptors(List tableNames) { HTableDescriptor[] htd = new HTableDescriptor[0]; + HBaseAdmin admin = null; try { LOG.info("getHTableDescriptors == tableNames => " + tableNames); - htd = new HBaseAdmin(getConf()).getTableDescriptorsByTableName(tableNames); + admin = new HBaseAdmin(getConf()); + htd = admin.getTableDescriptorsByTableName(tableNames); } catch (IOException e) { LOG.debug("Exception getting table descriptors", e); + } finally { + if (admin != null) { + try { + admin.close(); + } catch (IOException e) { + LOG.debug("Exception closing HBaseAdmin", e); + } + } } return htd; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java index 00c1c2b0936..80bf475a3bc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java @@ -125,8 +125,12 @@ class HMerge { "HBase instance must be running to merge a normal table"); } HBaseAdmin admin = new HBaseAdmin(conf); - if (!admin.isTableDisabled(tableName)) { - throw new TableNotDisabledException(tableName); + try { + if (!admin.isTableDisabled(tableName)) { + throw new TableNotDisabledException(tableName); + } + } finally { + admin.close(); } new OnlineMerger(conf, fs, tableName).process(); }