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 b98cee2f0 Add missing ExecutorService shutdown in test b98cee2f0 is described below commit b98cee2f0f5d3d9d1362c469c98374b578a39b48 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Feb 28 12:38:54 2024 -0500 Add missing ExecutorService shutdown in test --- .../commons/compress/compressors/GZipTest.java | 46 ++++++++++++---------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/compressors/GZipTest.java b/src/test/java/org/apache/commons/compress/compressors/GZipTest.java index 6d49aebe0..3971c5979 100644 --- a/src/test/java/org/apache/commons/compress/compressors/GZipTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/GZipTest.java @@ -65,31 +65,35 @@ public final class GZipTest extends AbstractTest { public void testCompress666() throws ExecutionException, InterruptedException { System.out.println("START"); final ExecutorService executorService = Executors.newFixedThreadPool(10); - final List<Future<?>> tasks = IntStream.range(0, 200).mapToObj(index -> executorService.submit(() -> { - TarArchiveEntry tarEntry = null; - try (InputStream inputStream = getClass().getResourceAsStream("/COMPRESS-666/compress-666.tar.gz"); - TarArchiveInputStream tarInputStream = new TarArchiveInputStream(new GZIPInputStream(inputStream))) { - while ((tarEntry = tarInputStream.getNextEntry()) != null) { - assertNotNull(tarEntry); + try { + final List<Future<?>> tasks = IntStream.range(0, 200).mapToObj(index -> executorService.submit(() -> { + TarArchiveEntry tarEntry = null; + try (InputStream inputStream = getClass().getResourceAsStream("/COMPRESS-666/compress-666.tar.gz"); + TarArchiveInputStream tarInputStream = new TarArchiveInputStream(new GZIPInputStream(inputStream))) { + while ((tarEntry = tarInputStream.getNextEntry()) != null) { + assertNotNull(tarEntry); + } + } catch (final IOException e) { + fail(Objects.toString(tarEntry), e); + } + })).collect(Collectors.toList()); + final List<Exception> list = new ArrayList<>(); + for (final Future<?> future : tasks) { + try { + future.get(); + } catch (final Exception e) { + list.add(e); } - } catch (final IOException e) { - fail(Objects.toString(tarEntry), e); } - })).collect(Collectors.toList()); - final List<Exception> list = new ArrayList<>(); - for (final Future<?> future : tasks) { - try { - future.get(); - } catch (final Exception e) { - list.add(e); + // check: + if (!list.isEmpty()) { + fail(list.get(0)); } + // or: + // assertTrue(list.isEmpty(), () -> list.size() + " exceptions: " + list.toString()); + } finally { + executorService.shutdownNow(); } - // check: - if (!list.isEmpty()) { - fail(list.get(0)); - } - // or: - // assertTrue(list.isEmpty(), () -> list.size() + " exceptions: " + list.toString()); } @Test