HBASE-10043 Fix Potential Resouce Leak in MultiTableInputFormatBase

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1549726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
eclark 2013-12-10 00:55:39 +00:00
parent 8ba036b72f
commit 0b737248c3
1 changed files with 17 additions and 8 deletions

View File

@ -83,15 +83,24 @@ public abstract class MultiTableInputFormatBase extends
new HTable(context.getConfiguration(), tSplit.getTableName());
TableRecordReader trr = this.tableRecordReader;
// if no table record reader was provided use default
if (trr == null) {
trr = new TableRecordReader();
try {
// if no table record reader was provided use default
if (trr == null) {
trr = new TableRecordReader();
}
Scan sc = tSplit.getScan();
sc.setStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setHTable(table);
} catch (IOException ioe) {
// If there is an exception make sure that all
// resources are closed and released.
table.close();
trr.close();
throw ioe;
}
Scan sc = tSplit.getScan();
sc.setStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setHTable(table);
return trr;
}