mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Restore host header initialization in StompBrokerRelayMessageHandler
Closes gh-36907
This commit is contained in:
+2
-2
@@ -456,7 +456,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||
accessor.setLogin(this.systemLogin);
|
||||
accessor.setPasscode(this.systemPasscode);
|
||||
accessor.setHeartbeat(this.systemHeartbeatSendInterval, this.systemHeartbeatReceiveInterval);
|
||||
accessor.setHost(getVirtualHost() != null ? getVirtualHost() : getRelayHost());
|
||||
accessor.setHost(getVirtualHost() != null ? getVirtualHost() : null);
|
||||
accessor.setSessionId(SYSTEM_SESSION_ID);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Forwarding " + accessor.getShortLogMessage(EMPTY_PAYLOAD));
|
||||
@@ -579,7 +579,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||
stompHeaderAccessor = (stompHeaderAccessor.isMutable() ? stompHeaderAccessor : StompHeaderAccessor.wrap(message));
|
||||
stompHeaderAccessor.setLogin(this.clientLogin);
|
||||
stompHeaderAccessor.setPasscode(this.clientPasscode);
|
||||
stompHeaderAccessor.setHost(getVirtualHost() != null ? getVirtualHost() : getRelayHost());
|
||||
stompHeaderAccessor.setHost(getVirtualHost() != null ? getVirtualHost() : null);
|
||||
RelayConnectionHandler handler = new RelayConnectionHandler(sessionId, stompHeaderAccessor);
|
||||
this.connectionHandlers.put(sessionId, handler);
|
||||
this.stats.incrementConnectCount();
|
||||
|
||||
+21
@@ -98,6 +98,27 @@ class StompBrokerRelayMessageHandlerTests {
|
||||
assertThat(headers2.getHost()).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
void virtualHostDefault() {
|
||||
Message<byte[]> connectMessage = connectMessage("sess1", "joe");
|
||||
MessageHeaderAccessor.getAccessor(connectMessage, StompHeaderAccessor.class).setHost("ABC");
|
||||
|
||||
this.brokerRelay.start();
|
||||
this.brokerRelay.handleMessage(connectMessage("sess1", "joe"));
|
||||
|
||||
assertThat(this.tcpClient.getSentMessages()).hasSize(2);
|
||||
|
||||
StompHeaderAccessor headers1 = this.tcpClient.getSentHeaders(0);
|
||||
assertThat(headers1.getCommand()).isEqualTo(StompCommand.CONNECT);
|
||||
assertThat(headers1.getSessionId()).isEqualTo(StompBrokerRelayMessageHandler.SYSTEM_SESSION_ID);
|
||||
assertThat(headers1.getHost()).isNull();
|
||||
|
||||
StompHeaderAccessor headers2 = this.tcpClient.getSentHeaders(1);
|
||||
assertThat(headers2.getCommand()).isEqualTo(StompCommand.CONNECT);
|
||||
assertThat(headers2.getSessionId()).isEqualTo("sess1");
|
||||
assertThat(headers2.getHost()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void loginAndPasscode() {
|
||||
this.brokerRelay.setSystemLogin("syslogin");
|
||||
|
||||
Reference in New Issue
Block a user