You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2013/07/02 21:40:42 UTC
svn commit: r1499072 - in /hadoop/common/branches/branch-1-win:
CHANGES.branch-1-win.txt src/core/org/apache/hadoop/fs/FileUtil.java
Author: cnauroth
Date: Tue Jul 2 19:40:42 2013
New Revision: 1499072
URL: http://svn.apache.org/r1499072
Log:
HADOOP-9681. FileUtil.unTarUsingJava() should close the InputStream upon finishing. Contributed by Chuan Liu.
Modified:
hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/fs/FileUtil.java
Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1499072&r1=1499071&r2=1499072&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Tue Jul 2 19:40:42 2013
@@ -279,6 +279,9 @@ Branch-hadoop-1-win (branched from branc
MAPREDUCE-5224. JobTracker should allow the system directory to be in
non-default FS. (Xi Fang via ivanmi)
+ HADOOP-9681. FileUtil.unTarUsingJava() should close the InputStream upon
+ finishing. (Chuan Liu via cnauroth)
+
Merged from branch-1
HDFS-385. Backport: Add support for an experimental API that allows a
Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/fs/FileUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/fs/FileUtil.java?rev=1499072&r1=1499071&r2=1499072&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/fs/FileUtil.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/fs/FileUtil.java Tue Jul 2 19:40:42 2013
@@ -561,18 +561,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);
}
}