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

Jaikiran Pai jpai at openjdk.org
Thu May 23 16:35:13 UTC 2024


On Thu, 23 May 2024 16:00:06 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

>> It would be an error if totalRead was > JTREG_AGENT_MAGIC.length: according to the logic of the code that reads the magic that cannot happen, ever. Hence the assert.
>
> right ... asserts are conditional on being enabled ... if the condition is a valid test then handled it properly and gracefully in the code not with a conditional abort

Hello Mark, the purpose of the assert is to catch any programming mistake/error. Where as the `if` block is to verify that the runtime handshake did indeed succeed.

At runtime, it is possible that an unexpectedly connected peer might send data that is less than what we expect in a handshake - the if block is meant to handle that case and close such connections.

The assert and and if serve two different purposes in this code.

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

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


More information about the jtreg-dev mailing list