Do not wrap problem with reading into an exception indicating write problem
@@ -105,6 +105,9 @@ final class TarArchiver extends Archiver {
try (InputStream fin = Files.newInputStream(file.toPath());
BoundedInputStream in = new BoundedInputStream(fin, size)) {
+ // Separate tray block not to wrap exception thrown while opening the input stream into an exception
+ // indicating a problem while writing
+ try {
int len;
while ((len = in.read(buf)) >= 0) {
tar.write(buf, 0, len);
@@ -114,6 +117,7 @@ final class TarArchiver extends Archiver {
throw ioE;
}
}
+ }
} finally { // always close the entry
tar.closeArchiveEntry();
}
