RFR: 7903730: Enhance the agentvm to be tolerant to unexpected connection on the port the Agent listens on for handshake with the AgentServer [v3]

Daniel Fuchs dfuchs at openjdk.org
Fri May 24 18:35:23 UTC 2024


On Fri, 24 May 2024 18:15:42 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

>> So we could do:
>> 
>> if (totalRead != JTREG_AGENT_HANDSHAKE_MAGIC.length) {
>>     assert totalRead < JTREG_AGENT_HANDSHAKE_MAGIC.length
>>    // problem
>> } else {
>>    // check for connect message
>> }
>
> just log the error and return null
> 
>            log("handshake failed - " + totalRead + " bytes received from " + s);
>             return null;
> 
> assert is the equivalent of a programming wart

I totally disagree: assert tells the reader the intention of the writer
The writer says: I have designed my code so that this condition will always be true. So I assert here. 

If the assert fails, then it means there's a programming error and the code must be revisited.

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

PR Review Comment: https://git.openjdk.org/jtreg/pull/195#discussion_r1613870336


More information about the jtreg-dev mailing list