[ https://issues.apache.org/jira/browse/COMPRESS-708?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory resolved COMPRESS-708. -------------------------------------- Fix Version/s: 1.29.0 Resolution: Fixed Hello [~yuweiboy] Thank you for the PR on GH. There is a simpler fix, which is now in git master and in snapshot builds (https://repository.apache.org/content/repositories/snapshots/org/apache/commons/commons-compress/1.29.0-SNAPSHOT/). You are credited in {{{}changes.xml{}}}. Please verify your use case and close this ticket if appropriate. TY! > ZstdCompressorInputStream closes the InputStream held by > ZipArchiveInputStream garbage collection > ------------------------------------------------------------------------------------------------- > > Key: COMPRESS-708 > URL: https://issues.apache.org/jira/browse/COMPRESS-708 > Project: Commons Compress > Issue Type: Bug > Reporter: 赵钰玮 > Priority: Major > Fix For: 1.29.0 > > Attachments: image-2025-09-03-22-46-38-243.png > > > {code:java} > @Test > void testZstdInputStreamErrorCloseWhenGc() throws Exception { > final File archive = getFile("COMPRESS-692/compress-692.zip"); > for (int i =0; i< 50;i++) { > try (FileInputStream fileInputStream = new FileInputStream(archive); > ZipArchiveInputStream zipArchiveInputStream = new > ZipArchiveInputStream(fileInputStream)){ > ArchiveEntry entry; > while ((entry = zipArchiveInputStream.getNextEntry()) != null) { > if (entry.isDirectory()) { > continue; > } > System.gc(); > IOUtils.toByteArray(zipArchiveInputStream); > } > } catch (IOException e) { > fail("testZstdInputStreamErrorCloseWhenGc error, test error at > batch " + (i+1), e); > } > } > } {code} > Here is the test method. Without the line {{{}System.gc();{}}}, it may take > multiple execution rounds to trigger the bug, but with this line added, the > bug is almost immediately triggered. Below is the error stack log. > !image-2025-09-03-22-46-38-243.png! > I found that this is caused by the following: The bug occurred because the > ZstdInputStream used in ZstdCompressorInputStream would close the underlying > InputStream during GC, which in turn caused errors like "stream closed" for > other wrapper streams (such as ZipArchiveInputStream) that depend on this > underlying stream. -- This message was sent by Atlassian Jira (v8.20.10#820010)