HBASE-8606 Meta scanner is not closed

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1485930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-05-24 03:35:09 +00:00
parent 23da6d4cd3
commit 65e1acd7a1
1 changed files with 23 additions and 3 deletions

View File

@ -127,6 +127,7 @@ public class MetaScanner {
HTable metaTable = new HTable(configuration, HConstants.META_TABLE_NAME);
// Calculate startrow for scan.
byte[] startRow;
ResultScanner scanner = null;
try {
if (row != null) {
// Scan starting at a particular row in a particular table
@ -160,7 +161,7 @@ public class MetaScanner {
Bytes.toStringBinary(startRow) + " for max=" + rowUpperLimit + " with caching=" + rows);
}
// Run the scan
ResultScanner scanner = metaTable.getScanner(scan);
scanner = metaTable.getScanner(scan);
Result result = null;
int processedRows = 0;
while ((result = scanner.next()) != null) {
@ -171,8 +172,27 @@ public class MetaScanner {
if (processedRows >= rowUpperLimit) break;
}
} finally {
if (visitor != null) visitor.close();
if (metaTable != null) metaTable.close();
if (scanner != null) {
try {
scanner.close();
} catch (Throwable t) {
LOG.debug("Got exception in closing the result scanner", t);
}
}
if (visitor != null) {
try {
visitor.close();
} catch (Throwable t) {
LOG.debug("Got exception in closing the meta scanner visitor", t);
}
}
if (metaTable != null) {
try {
metaTable.close();
} catch (Throwable t) {
LOG.debug("Got exception in closing the meta table", t);
}
}
}
}