From 25bb264bd97feb28d2efb80c3d53465aa534041e Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Thu, 26 Feb 2026 17:23:02 +0000 Subject: [PATCH] Polishing in ReactorNettyWebSocketClient Also, remove local variables that should have been removed when the corresponding, deprecated setters were removed in 2ed281f6a89d50fe042335a1c88b515cb254afff. Closes gh-36370 --- .../client/ReactorNettyWebSocketClient.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java index ea91a82191b..9c39fb191dd 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java @@ -51,10 +51,6 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { private final Supplier specBuilderSupplier; - private @Nullable Integer maxFramePayloadLength; - - private @Nullable Boolean handlePing; - /** * Default constructor. @@ -102,20 +98,14 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { * @since 5.3 */ public WebsocketClientSpec getWebsocketClientSpec() { - return buildSpec(null); + return buildWebSocketClientSpec(null); } - private WebsocketClientSpec buildSpec(@Nullable String protocols) { + private WebsocketClientSpec buildWebSocketClientSpec(@Nullable String protocols) { WebsocketClientSpec.Builder builder = this.specBuilderSupplier.get(); if (StringUtils.hasText(protocols)) { builder.protocols(protocols); } - if (this.maxFramePayloadLength != null) { - builder.maxFramePayloadLength(this.maxFramePayloadLength); - } - if (this.handlePing != null) { - builder.handlePing(this.handlePing); - } return builder.build(); } @@ -127,18 +117,18 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { @Override public Mono execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) { String protocols = StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()); - WebsocketClientSpec wsClientSpec = buildSpec(protocols); + WebsocketClientSpec clientSpec = buildWebSocketClientSpec(protocols); return getHttpClient() .headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders)) - .websocket(wsClientSpec) + .websocket(clientSpec) .uri(url.toString()) .handle((inbound, outbound) -> { HttpHeaders responseHeaders = toHttpHeaders(inbound); String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol"); HandshakeInfo info = new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol); NettyDataBufferFactory factory = new NettyDataBufferFactory(outbound.alloc()); - WebSocketSession session = new ReactorNettyWebSocketSession(inbound, outbound, info, factory, - wsClientSpec.maxFramePayloadLength()); + WebSocketSession session = new ReactorNettyWebSocketSession( + inbound, outbound, info, factory, clientSpec.maxFramePayloadLength()); if (logger.isDebugEnabled()) { logger.debug("Started session '" + session.getId() + "' for " + url); }