You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by pr...@apache.org on 2018/02/16 03:17:51 UTC

orc git commit: [ORC-301] `extractFileTail` should open a file in `try` statement

Repository: orc
Updated Branches:
  refs/heads/master d42067588 -> 28e88da63


[ORC-301] `extractFileTail` should open a file in `try` statement

Fixes #218

Signed-off-by: Prasanth Jayachandran <pr...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/28e88da6
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/28e88da6
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/28e88da6

Branch: refs/heads/master
Commit: 28e88da6365e3c7aa70baa423dbe77b5a9ebbdb5
Parents: d420675
Author: Dongjoon Hyun <do...@apache.org>
Authored: Wed Feb 14 15:07:24 2018 -0800
Committer: Prasanth Jayachandran <pr...@apache.org>
Committed: Thu Feb 15 19:17:32 2018 -0800

----------------------------------------------------------------------
 java/core/src/java/org/apache/orc/impl/ReaderImpl.java | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/28e88da6/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/ReaderImpl.java b/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
index e3f45ec..0daa0ed 100644
--- a/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
@@ -516,12 +516,11 @@ public class ReaderImpl implements Reader {
 
   protected OrcTail extractFileTail(FileSystem fs, Path path,
       long maxFileLength) throws IOException {
-    FSDataInputStream file = fs.open(path);
     ByteBuffer buffer;
     OrcProto.PostScript ps;
     OrcProto.FileTail.Builder fileTailBuilder = OrcProto.FileTail.newBuilder();
     long modificationTime;
-    try {
+    try (FSDataInputStream file = fs.open(path)) {
       // figure out the size of the file using the option or filesystem
       long size;
       if (maxFileLength == Long.MAX_VALUE) {
@@ -600,12 +599,6 @@ public class ReaderImpl implements Reader {
         OrcCodecPool.returnCodec(compressionKind, codec);
       }
       fileTailBuilder.setFooter(footer);
-    } finally {
-      try {
-        file.close();
-      } catch (IOException ex) {
-        LOG.error("Failed to close the file after another error", ex);
-      }
     }
 
     ByteBuffer serializedTail = ByteBuffer.allocate(buffer.remaining());