Skip to content

Commit 0e08e19

Browse files
committed
Merge pull request spring-projects#23793 from alexandrumm/ws-stomp-client-add-log
2 parents 248ad0f + 3895d21 commit 0e08e19

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@
5757
import org.springframework.web.socket.WebSocketMessage;
5858
import org.springframework.web.socket.WebSocketSession;
5959
import org.springframework.web.socket.client.WebSocketClient;
60+
import org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator;
6061
import org.springframework.web.socket.sockjs.transport.SockJsSession;
6162
import org.springframework.web.util.UriComponentsBuilder;
6263

@@ -265,7 +266,9 @@ public ListenableFuture<StompSession> connect(URI url, @Nullable WebSocketHttpHe
265266
Assert.notNull(url, "'url' must not be null");
266267
ConnectionHandlingStompSession session = createSession(connectHeaders, sessionHandler);
267268
WebSocketTcpConnectionHandlerAdapter adapter = new WebSocketTcpConnectionHandlerAdapter(session);
268-
getWebSocketClient().doHandshake(adapter, handshakeHeaders, url).addCallback(adapter);
269+
getWebSocketClient()
270+
.doHandshake(new LoggingWebSocketHandlerDecorator(adapter), handshakeHeaders, url)
271+
.addCallback(adapter);
269272
return session.getSessionFuture();
270273
}
271274

spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.web.socket.WebSocketHandler;
4747
import org.springframework.web.socket.WebSocketSession;
4848
import org.springframework.web.socket.client.WebSocketClient;
49+
import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
4950

5051
import static org.assertj.core.api.Assertions.assertThat;
5152
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -319,9 +320,12 @@ private WebSocketHandler connect() {
319320

320321
@SuppressWarnings("unchecked")
321322
private TcpConnection<byte[]> getTcpConnection() throws Exception {
322-
WebSocketHandler webSocketHandler = connect();
323-
webSocketHandler.afterConnectionEstablished(this.webSocketSession);
324-
return (TcpConnection<byte[]>) webSocketHandler;
323+
WebSocketHandler handler = connect();
324+
handler.afterConnectionEstablished(this.webSocketSession);
325+
if (handler instanceof WebSocketHandlerDecorator) {
326+
handler = ((WebSocketHandlerDecorator) handler).getLastHandler();
327+
}
328+
return (TcpConnection<byte[]>) handler;
325329
}
326330

327331
private void testInactivityTaskScheduling(Runnable runnable, long delay, long sleepTime)

0 commit comments

Comments
 (0)