You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/01 19:38:26 UTC
[commons-compress] branch master updated: Fix input stream resource leak in test.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 480b1a5 Fix input stream resource leak in test.
480b1a5 is described below
commit 480b1a524461ce58bc3f0e02622977179e283e13
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 1 14:38:24 2021 -0500
Fix input stream resource leak in test.
---
.../org/apache/commons/compress/compressors/Pack200TestCase.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
index 6e5520e..141a1e6 100644
--- a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
@@ -108,11 +108,15 @@ public final class Pack200TestCase extends AbstractTestCase {
ArchiveOutputStream os = ArchiveStreamFactory.DEFAULT.createArchiveOutputStream("jar", out)) {
os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
- IOUtils.copy(Files.newInputStream(file1.toPath()), os);
+ try (InputStream inputStream = Files.newInputStream(file1.toPath())) {
+ IOUtils.copy(inputStream, os);
+ }
os.closeArchiveEntry();
os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
- IOUtils.copy(Files.newInputStream(file2.toPath()), os);
+ try (InputStream inputStream = Files.newInputStream(file2.toPath())) {
+ IOUtils.copy(inputStream, os);
+ }
os.closeArchiveEntry();
}