RFR: 8233725: ProcessTools.startProcess() has output issues when using an OutputAnalyzer at the same time
Leonid Mesnik
lmesnik at openjdk.org
Tue Apr 25 04:08:06 UTC 2023
On Tue, 25 Apr 2023 03:06:09 GMT, Serguei Spitsyn <sspitsyn 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 792:
>
>> 790: @Override
>> 791: public InputStream getInputStream() {
>> 792: return out;
>
> This is a little bit confusing that the `getInputStream()` returns `out` stream.
> Just wanted to double-check if it is intentional and was not needed for `getOutputStream()` instead.
Agree, it is confusing, even in standard j.l.Process API . The `InputStream java.lang.Process.getInputStream()`" returns **output** stream of started process. So for our implementation ProcessImpl the 'out' and 'err' mean output and error streams. However they are returned as InputStreams so users could read them.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13594#discussion_r1175985058
More information about the serviceability-dev
mailing list