HBASE-10995 Fix resource leak related to unclosed HBaseAdmin

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1587966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2014-04-16 16:35:56 +00:00
parent 224aab57a0
commit d177b9b9a2
2 changed files with 17 additions and 3 deletions

View File

@ -2722,11 +2722,21 @@ public class HBaseFsck extends Configured {
HTableDescriptor[] getHTableDescriptors(List<TableName> 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;
}

View File

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