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
commit bd6ba252d8454b541d21bbadb613b834cc43aad9 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Sep 30 12:21:41 2023 -0400 Simplify exception handling --- .../commons/compress/archivers/zip/ZipFileTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java index f4bdc780..2a62104c 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java @@ -55,6 +55,7 @@ import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; +import org.apache.commons.io.function.IORunnable; import org.apache.commons.lang3.SystemUtils; import org.junit.Assume; import org.junit.jupiter.api.AfterEach; @@ -84,13 +85,11 @@ public class ZipFileTest extends AbstractTestCase { private ZipFile zf = null; - private void assertAllReadMethods(final byte[] expected, final ZipFile zipFile, final ZipArchiveEntry entry) { + private void assertAllReadMethods(final byte[] expected, final ZipFile zipFile, final ZipArchiveEntry entry) throws IOException { // simple IOUtil read try (InputStream stream = zf.getInputStream(entry)) { final byte[] full = IOUtils.toByteArray(stream); assertArrayEquals(expected, full); - } catch (final IOException ex) { - throw new AssertionError(ex); } // big buffer at the beginning and then chunks by IOUtils read @@ -445,14 +444,14 @@ public class ZipFileTest extends AbstractTestCase { } final AtomicInteger passedCount = new AtomicInteger(); - final Runnable run = () -> { + final IORunnable run = () -> { for (final ZipArchiveEntry entry: Collections.list(zf.getEntries())) { assertAllReadMethods(content.get(entry.getName()), zf, entry); } passedCount.incrementAndGet(); }; - final Thread t0 = new Thread(run); - final Thread t1 = new Thread(run); + final Thread t0 = new Thread(run.asRunnable()); + final Thread t1 = new Thread(run.asRunnable()); t0.start(); t1.start(); t0.join(); @@ -477,14 +476,14 @@ public class ZipFileTest extends AbstractTestCase { }} final AtomicInteger passedCount = new AtomicInteger(); - final Runnable run = () -> { + final IORunnable run = () -> { for (final ZipArchiveEntry entry : Collections.list(zf.getEntries())) { assertAllReadMethods(content.get(entry.getName()), zf, entry); } passedCount.incrementAndGet(); }; - final Thread t0 = new Thread(run); - final Thread t1 = new Thread(run); + final Thread t0 = new Thread(run.asRunnable()); + final Thread t1 = new Thread(run.asRunnable()); t0.start(); t1.start(); t0.join();