hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject svn commit: r1549725 - /hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java
Date Tue, 10 Dec 2013 00:55:32 GMT
Author: eclark
Date: Tue Dec 10 00:55:32 2013
New Revision: 1549725

URL: http://svn.apache.org/r1549725
Log:
HBASE-10043 Fix Potential Resouce Leak in MultiTableInputFormatBase

Modified:
    hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java

Modified: hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java?rev=1549725&r1=1549724&r2=1549725&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java
(original)
+++ hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java
Tue Dec 10 00:55:32 2013
@@ -83,15 +83,24 @@ public abstract class MultiTableInputFor
         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;
   }
 



Mime
View raw message