[
https://issues.apache.org/jira/browse/COMPRESS-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945432#comment-17945432
]
Alexis Jehan commented on COMPRESS-687:
---------------------------------------
After some months, I took the time to investigate the issue.
I found out that `System.out` does not print anything anymore after calling
`new Pack200CompressorInputStream`.
I temporary fixed it using this code:
{code:java}
public final class Foo {
public static void main(final String... args) throws IOException {
System.out.println("start");
final var out = System.out;
System.setOut(new PrintStream(OutputStream.nullOutputStream()));
try (var inputStream =
Foo.class.getClassLoader().getResourceAsStream("foo.pack")) {
try (var compressInputStream = new
Pack200CompressorInputStream(inputStream)) {
compressInputStream.transferTo(OutputStream.nullOutputStream());
}
}
System.setOut(out);
System.out.println("end"); // now reached
}
}
{code}
The library should not alter `System.out`. The fix should be applied here:
{noformat}
at
org.apache.commons.compress.harmony.unpack200.Segment.setLogStream(Segment.java:456)
at
org.apache.commons.compress.harmony.unpack200.Archive.unpack(Archive.java:207)
at
org.apache.commons.compress.harmony.unpack200.Pack200UnpackerAdapter.unpack(Pack200UnpackerAdapter.java:186)
at
org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream.<init>(Pack200CompressorInputStream.java:140)
at
org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream.<init>(Pack200CompressorInputStream.java:174)
{noformat}
> Pack200CompressorInputStream unexpected process finished on Java 22
> -------------------------------------------------------------------
>
> Key: COMPRESS-687
> URL: https://issues.apache.org/jira/browse/COMPRESS-687
> Project: Commons Compress
> Issue Type: Bug
> Components: Compressors
> Affects Versions: 1.27.1
> Reporter: Alexis Jehan
> Priority: Major
> Attachments: test-issue.7z
>
>
> Hello,
> Consider the following class:
> {code:java}
> public final class Foo {
> public static void main(final String... args) throws IOException {
> System.out.println("start");
> try (var inputStream =
> Foo.class.getClassLoader().getResourceAsStream("foo.pack")) {
> try (var compressInputStream = new
> Pack200CompressorInputStream(inputStream)) {
> compressInputStream.transferTo(System.out);
> }
> }
> System.out.println("end"); // never reached
> }
> }
> {code}
> Running it using Java 22, and the `--add-opens=java.base/java.io=ALL-UNNAMED`
> VM option, the result is:
> {noformat}
> start
> Process finished with exit code 0
> {noformat}
> The process is interrupted without any error.
> I have attached files.
> Thank you in advance.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)