diff options
author | Harald Musum <musum@yahooinc.com> | 2022-11-30 12:18:01 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-11-30 12:18:01 +0100 |
commit | f3b16fdc477da553e30a45b5ba624c2cf027fc07 (patch) | |
tree | 9abe888d859ced0fbc9973489f4992e9641d9fc0 /filedistribution | |
parent | c6a6f02c8218b677b2af737c6809db384450e2a4 (diff) |
Use transferTo for copying streams, avoid Guava
Diffstat (limited to 'filedistribution')
-rw-r--r-- | filedistribution/pom.xml | 4 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java | 12 |
2 files changed, 6 insertions, 10 deletions
diff --git a/filedistribution/pom.xml b/filedistribution/pom.xml index 74e06d4a9e3..6485919b14b 100644 --- a/filedistribution/pom.xml +++ b/filedistribution/pom.xml @@ -43,10 +43,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> </dependency> diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java index efb845bafe7..b6f84b979f5 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceCompressor.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; -import com.google.common.io.ByteStreams; import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockOutputStream; import org.apache.commons.compress.archivers.ArchiveEntry; @@ -87,9 +86,9 @@ public class FileReferenceCompressor { if (!parent.exists() && !parent.mkdirs()) { log.log(Level.WARNING, "Could not create dir " + parent.getAbsolutePath()); } - FileOutputStream fos = new FileOutputStream(outFile); - ByteStreams.copy(archiveInputStream, fos); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(outFile)) { + archiveInputStream.transferTo(fos); + } } entries++; } @@ -111,9 +110,10 @@ public class FileReferenceCompressor { } private static void writeFileToTar(ArchiveOutputStream taos, File baseDir, File file) throws IOException { - log.log(Level.FINEST, () -> "Adding file to tar: " + baseDir.toPath().relativize(file.toPath()).toString()); taos.putArchiveEntry(taos.createArchiveEntry(file, baseDir.toPath().relativize(file.toPath()).toString())); - ByteStreams.copy(new FileInputStream(file), taos); + try (FileInputStream inputStream = new FileInputStream(file)) { + inputStream.transferTo(taos); + } taos.closeArchiveEntry(); } |