Improve cancellation of read/write inactivity
The cancellation of read and write inactivity tasks was done via WebSocketHandler#afterConnectionClosed, relying on the WebSocket library to always invoke the callback. This change moves the cancellation to the `close` method instead that in turn is called from DefaultStompSession#resetConnection, in effect making the cancellation more proactive and aligned with connection cleanup in DefaultStompSession vs relying on a subsequent call from the WebSocket library after the connection is closed. Closes gh-32195
This commit is contained in:
@@ -302,7 +302,9 @@ class WebSocketStompClientTests {
|
||||
tcpConnection.onReadInactivity(mock(), 2L);
|
||||
tcpConnection.onWriteInactivity(mock(), 2L);
|
||||
|
||||
this.webSocketHandlerCaptor.getValue().afterConnectionClosed(this.webSocketSession, CloseStatus.NORMAL);
|
||||
WebSocketHandler handler = this.webSocketHandlerCaptor.getValue();
|
||||
TcpConnection<?> connection = (TcpConnection<?>) WebSocketHandlerDecorator.unwrap(handler);
|
||||
connection.close();
|
||||
|
||||
verify(future, times(2)).cancel(true);
|
||||
verifyNoMoreInteractions(future);
|
||||
|
||||
Reference in New Issue
Block a user