Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dear Maintainer,
I noticed that one of the WebSocket tests in the repository is exhibiting flaky behavior due to Non-Order-Determinism (NOD) issues. Below is a detailed explanation of the problem and a proposed fix to ensure the test behaves reliably.
Occasionally, the test fails at the line:
undertow/websockets-jsr/src/test/java/io/undertow/websockets/jsr/test/reconnect/ClientEndpointReconnectTestCase.java
Line 117 in b44a1c3
with the error:
expected:<[MESSAGE-ECHO-hi]> but was:<[CLOSE]>
The issue stems from Non-Order-Determinism (NOD) in the asynchronous WebSocket communication. Specifically:
Race Condition During Reconnection: After sending the "close" message, the test immediately proceeds to send "hi" without ensuring that the WebSocket connection has been fully reopened.
The "CLOSE" message from the previous interaction might still be processed or pending when "hi" is sent, causing the test to retrieve "CLOSE" instead of "MESSAGE-ECHO-hi".
Session State Assumption: The test assumes that the Session is immediately ready to send and receive messages after receiving an "OPEN" message, which may not be the case in all scenarios.
Unreliable Message Processing Order: WebSocket communication is asynchronous, and the test does not synchronize properly with the server's message processing, leading to unexpected order of messages.
Proposed Fix
To resolve the issue, I propose the following change: Verify session state before sending messages by adding a check to ensure the Session is open and ready for communication. This change ensure the test behaves reliably by addressing the Non-Order-Determinism issue caused by race conditions in the asynchronous WebSocket communication.
Please let me know if you’d like further clarification or assistance with implementing these changes.
Best regards,