RFR: 8233725: ProcessTools.startProcess() has output issues when using an OutputAnalyzer at the same time

Leonid Mesnik lmesnik at openjdk.org
Tue Apr 25 01:46:06 UTC 2023


On Mon, 24 Apr 2023 20:57:31 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>> ProcessTools.startProcess() creates process and read it's output error streams. So the any other using of corresponding Process.getInputStream() and Process.getErrorStream() doesn't get process streams.
>> 
>> This fix preserve process streams content and allow to read reuse the date. The ByteArrayOutputStream is used as a buffer. 
>> It stores all process output, never trying to clean date which has been read. 
>> 
>> The regression test has been provided with issue.
>> 
>> I closed previous PR https://github.com/openjdk/jdk/pull/13560 by mistake instead of updating it.
>> 
>> I run all tests to ensure that no failures are introduced.
>
> test/lib/jdk/test/lib/process/ProcessTools.java line 249:
> 
>> 247:         stdout.addOutputStream(out.getOutputStream());
>> 248:         stderr.addOutputStream(err.getOutputStream());
>> 249: 
> 
> Overall this looks good, although I'm a bit unclear on how some of the underpinnings work, allowing the output to appear in these output streams, and also in the LineForwarder output (above), and for that matter, in the lineConsumer output (below). I guess there is some multiplexing of the output that I just don't grasp, but appears to be something that already worked.

StreamPumper read process stdout, stderr streams and write read data to registered streams. So it works as multiplexer.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13594#discussion_r1175930914


More information about the serviceability-dev mailing list