From 900dd0c3eb1125a068f6f3401e937d4b71aca8be Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 30 Jun 2025 17:29:36 +0200 Subject: [PATCH] Polish contribution See gh-35132 --- .../ConcurrentWebSocketSessionDecorator.java | 25 ++++++++++--------- ...currentWebSocketSessionDecoratorTests.java | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java index 5089c22cdb..22f23579ec 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java @@ -36,10 +36,10 @@ import org.springframework.web.socket.WebSocketSession; * Wrap a {@link org.springframework.web.socket.WebSocketSession WebSocketSession} * to guarantee only one thread can send messages at a time. * - *
If a send is slow, subsequent attempts to send more messages from other threads - * will not be able to acquire the flush lock and messages will be buffered instead. - * At that time, the specified buffer-size limit and send-time limit will be checked - * and the session will be closed if the limits are exceeded. + *
If a {@code send} is slow, subsequent attempts to send more messages from + * other threads will not be able to acquire the flush lock, and messages will be + * buffered instead. At that time, the specified buffer-size limit and send-time + * limit will be checked, and the session will be closed if the limits are exceeded. * * @author Rossen Stoyanchev * @author Juergen Hoeller @@ -91,7 +91,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat * @param sendTimeLimit the send-time limit (milliseconds) * @param bufferSizeLimit the buffer-size limit (number of bytes) * @param overflowStrategy the overflow strategy to use; by default the - * session is terminated. + * session is terminated * @since 5.1 */ public ConcurrentWebSocketSessionDecorator( @@ -120,6 +120,14 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat return this.bufferSizeLimit; } + /** + * Return the configured {@link OverflowStrategy}. + * @since 6.2.9 + */ + public OverflowStrategy getOverflowStrategy() { + return this.overflowStrategy; + } + /** * Return the current buffer size (number of bytes). */ @@ -276,13 +284,6 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat } } - /** - * Return the configured overflow strategy. - * @since 6.3 - */ - public OverflowStrategy getOverflowStrategy() { - return this.overflowStrategy; - } @Override public String toString() { diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java index da08400d94..85678fce77 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java @@ -218,7 +218,8 @@ class ConcurrentWebSocketSessionDecoratorTests { @Test void configuredProperties() { TestWebSocketSession session = new TestWebSocketSession(); - ConcurrentWebSocketSessionDecorator sessionDecorator = new ConcurrentWebSocketSessionDecorator(session, 42, 43, OverflowStrategy.DROP); + ConcurrentWebSocketSessionDecorator sessionDecorator = + new ConcurrentWebSocketSessionDecorator(session, 42, 43, OverflowStrategy.DROP); assertThat(sessionDecorator.getSendTimeLimit()).isEqualTo(42); assertThat(sessionDecorator.getBufferSizeLimit()).isEqualTo(43);