HADOOP-15962. The buffer size is small when unpacking tar archives. Contributed by BELUGA BEHR.

This commit is contained in:
Akira Ajisaka 2018-12-28 15:38:23 +09:00
parent d8f670ff28
commit 57198bc511
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50

View File

@ -918,12 +918,13 @@ static void unTarUsingJava(File inFile, File untarDir,
TarArchiveInputStream tis = null;
try {
if (gzipped) {
inputStream = new BufferedInputStream(new GZIPInputStream(
new FileInputStream(inFile)));
inputStream = new GZIPInputStream(new FileInputStream(inFile));
} else {
inputStream = new BufferedInputStream(new FileInputStream(inFile));
inputStream = new FileInputStream(inFile);
}
inputStream = new BufferedInputStream(inputStream);
tis = new TarArchiveInputStream(inputStream);
for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
@ -940,13 +941,9 @@ private static void unTarUsingJava(InputStream inputStream, File untarDir,
TarArchiveInputStream tis = null;
try {
if (gzipped) {
inputStream = new BufferedInputStream(new GZIPInputStream(
inputStream));
} else {
inputStream =
new BufferedInputStream(inputStream);
inputStream = new GZIPInputStream(inputStream);
}
inputStream = new BufferedInputStream(inputStream);
tis = new TarArchiveInputStream(inputStream);
for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
@ -1002,17 +999,7 @@ private static void unpackEntries(TarArchiveInputStream tis,
return;
}
int count;
byte data[] = new byte[2048];
try (BufferedOutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(outputFile));) {
while ((count = tis.read(data)) != -1) {
outputStream.write(data, 0, count);
}
outputStream.flush();
}
org.apache.commons.io.FileUtils.copyToFile(tis, outputFile);
}
/**