-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #3494 - flaky tests in jetty-websocket-tests ClientCloseTest #3521
Issue #3494 - flaky tests in jetty-websocket-tests ClientCloseTest #3521
Conversation
Nulling out values in WebSocketAdapter causes race conditions when trying to access session and endpoint externally Race condition in WebSocketChannel.Flusher.onCompleteFailure(), processConnectionError should be called first to ensure that the correct close reason is processed, super.onCompleteFailure() was closing the connection causing a read failure. race condition between the server detecting a read failure and sending a response and the client detecting the write failure, now blocking on the server so it is not reading and will not detect the failure Signed-off-by: lachan-roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…rror WebSocketChannel.processConnectionError now defaults to NO_CLOSE status if no protocol reasons can be found added some debug logging improvements to tests Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor niggles, not worth impacting this PR, but should probably be addressed elsewhere.
@@ -59,8 +59,7 @@ public void onWebSocketBinary(byte[] payload, int offset, int len) | |||
@Override | |||
public void onWebSocketClose(int statusCode, String reason) | |||
{ | |||
this.session = null; | |||
this.remote = null; | |||
/* do nothing */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go this route, then we MUST make sure that the session / remote are not capable of being used after onWebSocketClose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the session after the close has happened will result in Session.isOpen()
returning false and any writes on the RemoteEndpoint
are failed, so they are safe to keep around after the close
although maybe we need test cases to verify this behaviour
...-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientCloseTest.java
Show resolved
Hide resolved
@joakime I don't have the permissions to merge, so can you merge it if there's no further changes you want |
…-3494-clientclosetest Signed-off-by: lachan-roberts <lachlan@webtide.com>
0094dba
to
002ecf5
Compare
#3494
Nulling out values in
WebSocketAdapter
causes race conditions when trying to access session and endpoint externally which was causing errors in the tests, if you calladapter.getSession().close()
the socket could receive a close just before null out the session and then you get a NPEThere was a race condition in
WebSocketChannel.Flusher.onCompleteFailure()
, whereprocessConnectionError()
should be called beforesuper.onCompleteFailure()
to ensure that thecorrect close reason is processed before the channel is closed.
In
testWriteException
when the output was shutdown there was a race condition between the client detecting the write failure and the server detecting a read failure and sending a failure response.We now send a message to block the server from reading so that it will not detect the failure and respond.