Skip to content

[core] If report is written to stdout, stdout should not be closed #4031

@adangel

Description

@adangel

Description:

Found in #4023 (comment) and #4023 (comment)

I've added a report output file as otherwise we report to stdout.
And we close the report files afterwards - which is why we close stdout.
We have a outStreamCaptor active, however, the close is delegated to the original stdout stream.
Closing stdout in a unit test is not good for IntelliJ IDEA, as IntelliJ IDEA uses this channel
to communicate test progress etc...

I think we should never close stdout,,, We should use something similar to https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/output/CloseShieldWriter.html

This might be a problem, when PMD is integrated as a library (e.g. just calling PMD.run(...)) and no report file given. Then PMD will write the report to stdout and close it afterwards... and the calling process now has a closed stdout.

Metadata

Metadata

Assignees

Labels

a:bugPMD crashes or fails to analyse a file.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions