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 3c3c2f01 Use try-with-resources
3c3c2f01 is described below
commit 3c3c2f010bbcabf7fca96ec04ef542d6da527491
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Nov 4 06:38:10 2023 -0400
Use try-with-resources
---
.../commons/compress/archivers/zip/DataDescriptorTest.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
index ce143409..b9e3125f 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
@@ -24,6 +24,7 @@ import static
org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Arrays;
@@ -95,11 +96,12 @@ public class DataDescriptorTest {
}
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final ZipArchiveEntry zae;
try (ZipFile zf = new ZipFile(f);
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(baos)) {
- zae = zf.getEntry("test1.txt");
- zos.addRawArchiveEntry(zae, zf.getRawInputStream(zae));
+ ZipArchiveOutputStream zos = new ZipArchiveOutputStream(baos))
{
+ final ZipArchiveEntry zae = zf.getEntry("test1.txt");
+ try (InputStream rawInputStream = zf.getRawInputStream(zae)) {
+ zos.addRawArchiveEntry(zae, rawInputStream);
+ }
}
final byte[] data = baos.toByteArray();