HADOOP-9681. FileUtil.unTarUsingJava() should close the InputStream upon finishing. Contributed by Chuan Liu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1499069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70e9e58ff3
commit
3628553736
|
@ -784,6 +784,9 @@ Release 2.1.0-beta - 2013-07-02
|
||||||
HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows.
|
HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows.
|
||||||
(Ivan Mitic via cnauroth)
|
(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
|
HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather
|
||||||
than throw EOF at end of file. (Zhijie Shen via acmurthy)
|
than throw EOF at end of file. (Zhijie Shen via acmurthy)
|
||||||
|
|
||||||
|
|
|
@ -662,18 +662,23 @@ public class FileUtil {
|
||||||
private static void unTarUsingJava(File inFile, File untarDir,
|
private static void unTarUsingJava(File inFile, File untarDir,
|
||||||
boolean gzipped) throws IOException {
|
boolean gzipped) throws IOException {
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
if (gzipped) {
|
TarArchiveInputStream tis = null;
|
||||||
inputStream = new BufferedInputStream(new GZIPInputStream(
|
try {
|
||||||
new FileInputStream(inFile)));
|
if (gzipped) {
|
||||||
} else {
|
inputStream = new BufferedInputStream(new GZIPInputStream(
|
||||||
inputStream = new BufferedInputStream(new FileInputStream(inFile));
|
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;) {
|
for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
|
||||||
unpackEntries(tis, entry, untarDir);
|
unpackEntries(tis, entry, untarDir);
|
||||||
entry = tis.getNextTarEntry();
|
entry = tis.getNextTarEntry();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
IOUtils.cleanup(LOG, tis, inputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue