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

Serguei Spitsyn sspitsyn at openjdk.org
Tue Apr 25 03:09:08 UTC 2023


On Fri, 21 Apr 2023 21:43:39 GMT, Leonid Mesnik <lmesnik 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.

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

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


More information about the serviceability-dev mailing list