From a0f8dc4fa5c7d83dfb7c7d7e617c698ffae53a77 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Sat, 18 May 2024 04:01:24 +0200 Subject: [PATCH] [WIP] Prevent premature closure of input streams Oops, we missed this difference from e0a4a118 --- .../copy/archive/impl/SevenZipArchiveSourceInternalSpec.java | 4 +++- .../io/copy/archive/impl/TarArchiveSourceInternalSpec.java | 4 +++- .../impl/process/ProcessArchiveSourceInternalSpec.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/SevenZipArchiveSourceInternalSpec.java b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/SevenZipArchiveSourceInternalSpec.java index 3f0adb6..0d87d8b 100644 --- a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/SevenZipArchiveSourceInternalSpec.java +++ b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/SevenZipArchiveSourceInternalSpec.java @@ -49,7 +49,9 @@ public FileTimes getFileTimes() { @Override public InputStream getInputStream() { if (inputStream == null) { - inputStream = new BoundedInputStream(new SevenZFileInputStream(sevenZFile), sevenZArchiveEntry.getSize()); + BoundedInputStream boundedInputStream = new BoundedInputStream(new SevenZFileInputStream(sevenZFile), sevenZArchiveEntry.getSize()); + boundedInputStream.setPropagateClose(false); + inputStream = boundedInputStream; } return inputStream; } diff --git a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/TarArchiveSourceInternalSpec.java b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/TarArchiveSourceInternalSpec.java index ce5cda4..b65ee70 100644 --- a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/TarArchiveSourceInternalSpec.java +++ b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/TarArchiveSourceInternalSpec.java @@ -76,7 +76,9 @@ private static FileTime fromEpochSeconds(@Nullable String seconds, @Nullable Dat @Override public InputStream getInputStream() { if (inputStream == null) { - inputStream = new BoundedInputStream(tarArchiveInputStream, tarArchiveEntry.getRealSize()); + BoundedInputStream boundedInputStream = new BoundedInputStream(tarArchiveInputStream, tarArchiveEntry.getRealSize()); + boundedInputStream.setPropagateClose(false); + inputStream = boundedInputStream; } return inputStream; } diff --git a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/process/ProcessArchiveSourceInternalSpec.java b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/process/ProcessArchiveSourceInternalSpec.java index 245067a..cd5a539 100644 --- a/core/src/main/java/io/github/datromtool/io/copy/archive/impl/process/ProcessArchiveSourceInternalSpec.java +++ b/core/src/main/java/io/github/datromtool/io/copy/archive/impl/process/ProcessArchiveSourceInternalSpec.java @@ -46,7 +46,9 @@ public FileTimes getFileTimes() { @Override public InputStream getInputStream() { if (inputStream == null) { - inputStream = new BoundedInputStream(processInputStream, file.getSize()); + BoundedInputStream boundedInputStream = new BoundedInputStream(processInputStream, file.getSize()); + boundedInputStream.setPropagateClose(false); + inputStream = boundedInputStream; } return inputStream; }