RFR: 7903441: System.out and System.err messages are missing in jtr file when a test times out in agentvm mode [v2]
Jaikiran Pai
jpai at openjdk.org
Fri May 12 05:28:04 UTC 2023
On Thu, 11 May 2023 00:58:01 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> Can I please get a review of this change which proposes to fix the issue reported in https://bugs.openjdk.org/browse/CODETOOLS-7903441?
>>
>> As noted in that issue, when a test timeouts when run in the agent vm mode, it has been noticed that the System.out/System.err messages that were written by the test are lost and not present in the .jtr file of that test.
>>
>> There are 2 parts to this issue and this PR thus has 2 separate commits to help review this.
>>
>> Agent VM test execution involves communicating between processes - the jtreg process (a.k.a `Agent`) and the process that is executing the test case (a.k.a `AgentServer`), through sockets. One part of this communication involves sending across the System.out and System.err generated messages from the `AgentServer` VM to the `Agent`. As part of https://bugs.openjdk.org/browse/CODETOOLS-7902198, work was done to help send across these messages in a timely fashion. One part of that change involves converting the byte oriented messages into characters. This is done using a `CharsetDecoder` which decodes `ByteBuffer` contents to a `CharBuffer`. Once the decoded content lands into the `charBuffer` it stays in that buffer until either the OutputStream is closed or the `charBuffer` capacity has been reached. Even a `flush()` call doesn't push out these decoded characters into the target/underlying OutputStream and that results in lost messages. The commit https://github.com/openjdk/jtreg/
commit/578e103dcb911c07c59007138e62a78c3abba6d7 in this PR addresses that by making sure `flush()` operation on the `OutputStream` does indeed flush the decoded characters to the underlying stream, thus allowing it to reach the other process.
>>
>> In the current jtreg code, the compile action and main action implementation on the `AgentServer` side both use `autoFlush=true` for `System.err` but not for `System.out`, I couldn't find an explanation why `System.out` explicitly sets `autoFlush=false`. The additional commit https://github.com/openjdk/jtreg/commit/1d08b7656d46c124730c6844fefc595804266d36 in this PR addresses this by setting `System.out` as `autoFlush=true`. Auto-flush is defined by `java.io.PrintStream` as:
>>
>>> Optionally, a {@code PrintStream} can be created so as to flush automatically; this means that the {@code flush} method of the underlying output stream is automatically invoked after a byte array is written, one of the {@code println} methods is invoked, or a newline character or byte ({@code '\n'}) is...
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>
> review suggestion - fix grammar in code comment
Additional testing on CI for JDK builds went fine. I'll go ahead and integrate this now.
-------------
PR Comment: https://git.openjdk.org/jtreg/pull/155#issuecomment-1545186639
More information about the jtreg-dev
mailing list