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
1 changed files with 7 additions and 20 deletions

View File

@ -918,12 +918,13 @@ public class FileUtil {
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 @@ public class FileUtil {
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 @@ public class FileUtil {
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);
}
/**