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 09ae85b59 Reuse NIO API instead of custom code
09ae85b59 is described below

commit 09ae85b59fed143578b0d170cc19464577d0405a
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Nov 14 13:59:53 2023 -0500

    Reuse NIO API instead of custom code
---
 .../compress/archivers/zip/ZipArchiveInputStreamTest.java        | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index f13369234..7061dc0ed 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
@@ -36,6 +35,7 @@ import java.io.InputStream;
 import java.nio.channels.Channels;
 import java.nio.channels.SeekableByteChannel;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.Instant;
 import java.util.Arrays;
@@ -359,11 +359,10 @@ public class ZipArchiveInputStreamTest extends 
AbstractTest {
      */
     @Test
     public void testReadDeflate64CompressedStream() throws Exception {
-        final File input = getFile("COMPRESS-380/COMPRESS-380-input");
+        final Path input = getPath("COMPRESS-380/COMPRESS-380-input");
         final File archive = getFile("COMPRESS-380/COMPRESS-380.zip");
-        try (InputStream in = Files.newInputStream(input.toPath());
-                ZipArchiveInputStream zin = new 
ZipArchiveInputStream(Files.newInputStream(archive.toPath()))) {
-            final byte[] orig = IOUtils.toByteArray(in);
+        try (ZipArchiveInputStream zin = new 
ZipArchiveInputStream(Files.newInputStream(archive.toPath()))) {
+            final byte[] orig = Files.readAllBytes(input);
             final ZipArchiveEntry e = zin.getNextZipEntry();
             final byte[] fromZip = IOUtils.toByteArray(zin);
             assertArrayEquals(orig, fromZip);

Reply via email to