diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-04-03 09:48:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 09:48:13 +0200 |
commit | 89e479cf8494415b1ba3ce1adbdbe2b41c2de517 (patch) | |
tree | 503650c72f1690b4c375ff732bbb5fe91b68cba4 /filedistribution | |
parent | 57a22250dd584eec38652b559ff5adb6f394ba8d (diff) | |
parent | 6a9a2ee69e08c9891875a6d6ce2d7b192666ce09 (diff) |
Merge pull request #5441 from vespa-engine/hmusum/throw-exception-when-unable-to-decompress
Throw exception when unable to decompress
Diffstat (limited to 'filedistribution')
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/CompressedFileReference.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/CompressedFileReference.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/CompressedFileReference.java index c4cd2a073c1..a1ad5c8a200 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/CompressedFileReference.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/CompressedFileReference.java @@ -64,9 +64,11 @@ public class CompressedFileReference { static void decompress(File inputFile, File outputDir) throws IOException { log.log(LogLevel.DEBUG, () -> "Decompressing '" + inputFile + "' into '" + outputDir + "'"); - ArchiveInputStream ais = new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(inputFile))); - decompress(ais, outputDir); - ais.close(); + try (ArchiveInputStream ais = new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(inputFile)))) { + decompress(ais, outputDir); + } catch (IllegalArgumentException e) { + throw new RuntimeException("Unable to decompress '" + inputFile.getAbsolutePath() + "': " + e.getMessage()); + } } private static void decompress(ArchiveInputStream archiveInputStream, File outputFile) throws IOException { @@ -95,7 +97,8 @@ public class CompressedFileReference { entries++; } if (entries == 0) { - log.log(LogLevel.WARNING, "Not able to read any entries from " + outputFile.getName()); + throw new IllegalArgumentException("Not able to read any entries from stream (" + + archiveInputStream.getBytesRead() + " bytes read from stream)"); } } |