提交 d3f75a90 编写于 作者: O Oliver Gondža

[JENKINS-21905] Do not wrap problem with reading into an exception indicating write problem

上级 3f3e3b80
......@@ -102,16 +102,20 @@ final class TarArchiver extends Archiver {
try {
if (!file.isDirectory()) {
// ensure we don't write more bytes than the declared when we created the entry
try (InputStream fin = Files.newInputStream(file.toPath());
BoundedInputStream in = new BoundedInputStream(fin, size)) {
int len;
while ((len = in.read(buf)) >= 0) {
tar.write(buf, 0, len);
// 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);
}
} catch (IOException | InvalidPathException e) {// log the exception in any case
IOException ioE = new IOException("Error writing to tar file from: " + file, e);
throw ioE;
}
} catch (IOException | InvalidPathException e) {// log the exception in any case
IOException ioE = new IOException("Error writing to tar file from: " + file, e);
throw ioE;
}
}
} finally { // always close the entry
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册