Use channelId for ReactorNettyWebSocketSession's id

Closes gh-35883
This commit is contained in:
rstoyanchev
2025-12-01 11:01:04 +00:00
parent 1603045c7d
commit 4ae03ecd40
2 changed files with 20 additions and 5 deletions
@@ -61,9 +61,20 @@ public abstract class NettyWebSocketSessionSupport<T> extends AbstractWebSocketS
messageTypes.put(PongWebSocketFrame.class, WebSocketMessage.Type.PONG);
}
/**
* Constructor that uses the hashcode of the delegate as the session id.
*/
protected NettyWebSocketSessionSupport(T delegate, HandshakeInfo info, NettyDataBufferFactory factory) {
super(delegate, ObjectUtils.getIdentityHexString(delegate), info, factory);
this(delegate, ObjectUtils.getIdentityHexString(delegate), info, factory);
}
/**
* Variant of {@link #NettyWebSocketSessionSupport(Object, HandshakeInfo, NettyDataBufferFactory)}
* with a given WebSocket session id.
* @since 6.2.15
*/
protected NettyWebSocketSessionSupport(T delegate, String id, HandshakeInfo info, NettyDataBufferFactory factory) {
super(delegate, id, info, factory);
}
@@ -64,14 +64,18 @@ public class ReactorNettyWebSocketSession
* Constructor with an additional maxFramePayloadLength argument.
* @since 5.1
*/
@SuppressWarnings("rawtypes")
public ReactorNettyWebSocketSession(WebsocketInbound inbound, WebsocketOutbound outbound,
HandshakeInfo info, NettyDataBufferFactory bufferFactory,
int maxFramePayloadLength) {
super(new WebSocketConnection(inbound, outbound), info, bufferFactory);
super(new WebSocketConnection(inbound, outbound), getChannelId(inbound).asLongText(), info, bufferFactory);
this.maxFramePayloadLength = maxFramePayloadLength;
this.channelId = ((ChannelOperations) inbound).channel().id();
this.channelId = getChannelId(inbound);
}
@SuppressWarnings("rawtypes")
private static ChannelId getChannelId(WebsocketInbound inbound) {
return ((ChannelOperations) inbound).channel().id();
}