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:
parent
8ba036b72f
commit
0b737248c3
|
@ -83,6 +83,8 @@ public abstract class MultiTableInputFormatBase extends
|
|||
new HTable(context.getConfiguration(), tSplit.getTableName());
|
||||
|
||||
TableRecordReader trr = this.tableRecordReader;
|
||||
|
||||
try {
|
||||
// if no table record reader was provided use default
|
||||
if (trr == null) {
|
||||
trr = new TableRecordReader();
|
||||
|
@ -92,6 +94,13 @@ public abstract class MultiTableInputFormatBase extends
|
|||
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;
|
||||
}
|
||||
return trr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue