You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/10/23 01:37:29 UTC

svn commit: r1534850 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java

Author: stack
Date: Tue Oct 22 23:37:29 2013
New Revision: 1534850

URL: http://svn.apache.org/r1534850
Log:
HBASE-9737 Corrupt HFile cause resource leak leading to Region Server OOM

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java?rev=1534850&r1=1534849&r2=1534850&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Tue Oct 22 23:37:29 2013
@@ -522,18 +522,23 @@ public class HFile {
       boolean isHBaseChecksum = fsdis.shouldUseHBaseChecksum();
       assert !isHBaseChecksum; // Initially we must read with FS checksum.
       trailer = FixedFileTrailer.readFromStream(fsdis.getStream(isHBaseChecksum), size);
-    } catch (IllegalArgumentException iae) {
-      throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, iae);
-    }
-    switch (trailer.getMajorVersion()) {
-    case 2:
-      return new HFileReaderV2(
-          path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
-    case 3 :
-      return new HFileReaderV3(
-          path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
-    default:
-      throw new CorruptHFileException("Invalid HFile version " + trailer.getMajorVersion());
+      switch (trailer.getMajorVersion()) {
+      case 2:
+        return new HFileReaderV2(
+            path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
+      case 3 :
+        return new HFileReaderV3(
+            path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
+      default:
+        throw new IllegalArgumentException("Invalid HFile version " + trailer.getMajorVersion());
+      }
+    } catch (Throwable t) {
+      try {
+        fsdis.close();
+      } catch (Throwable t2) {
+        LOG.warn("Error closing fsdis FSDataInputStreamWrapper", t2);
+      }
+      throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, t);
     }
   }