hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject svn commit: r1499070 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/fs/FileUtil.java
Date Tue, 02 Jul 2013 19:27:16 GMT
Author: cnauroth
Date: Tue Jul  2 19:27:16 2013
New Revision: 1499070

URL: http://svn.apache.org/r1499070
Log:
HADOOP-9681. Merging change r1499069 from trunk to branch-2.

Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1499070&r1=1499069&r2=1499070&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Tue Jul
 2 19:27:16 2013
@@ -518,6 +518,9 @@ Release 2.1.0-beta - 2013-07-02
     HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows.
     (Ivan Mitic via cnauroth)
 
+    HADOOP-9681. FileUtil.unTarUsingJava() should close the InputStream upon
+    finishing. (Chuan Liu via cnauroth)
+
     HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather
     than throw EOF at end of file. (Zhijie Shen via acmurthy)
 

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java?rev=1499070&r1=1499069&r2=1499070&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
Tue Jul  2 19:27:16 2013
@@ -662,18 +662,23 @@ public class FileUtil {
   private static void unTarUsingJava(File inFile, File untarDir,
       boolean gzipped) throws IOException {
     InputStream inputStream = null;
-    if (gzipped) {
-      inputStream = new BufferedInputStream(new GZIPInputStream(
-          new FileInputStream(inFile)));
-    } else {
-      inputStream = new BufferedInputStream(new FileInputStream(inFile));
-    }
+    TarArchiveInputStream tis = null;
+    try {
+      if (gzipped) {
+        inputStream = new BufferedInputStream(new GZIPInputStream(
+            new FileInputStream(inFile)));
+      } else {
+        inputStream = new BufferedInputStream(new FileInputStream(inFile));
+      }
 
-    TarArchiveInputStream tis = new TarArchiveInputStream(inputStream);
+      tis = new TarArchiveInputStream(inputStream);
 
-    for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
-      unpackEntries(tis, entry, untarDir);
-      entry = tis.getNextTarEntry();
+      for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
+        unpackEntries(tis, entry, untarDir);
+        entry = tis.getNextTarEntry();
+      }
+    } finally {
+      IOUtils.cleanup(LOG, tis, inputStream);
     }
   }
   



Mime
View raw message