Merge branch '6.2.x'
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions Details
Deploy Docs / Dispatch docs deployment (push) Waiting to run Details

This commit is contained in:
Sam Brannen 2025-06-30 17:39:17 +02:00
commit 60b19278c0
2 changed files with 24 additions and 5 deletions

View File

@ -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.
*
* <p>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.
* <p>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
@ -90,7 +90,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(
@ -119,6 +119,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).
*/

View File

@ -215,4 +215,15 @@ class ConcurrentWebSocketSessionDecoratorTests {
assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue();
}
@Test
void configuredProperties() {
TestWebSocketSession session = new TestWebSocketSession();
ConcurrentWebSocketSessionDecorator sessionDecorator =
new ConcurrentWebSocketSessionDecorator(session, 42, 43, OverflowStrategy.DROP);
assertThat(sessionDecorator.getSendTimeLimit()).isEqualTo(42);
assertThat(sessionDecorator.getBufferSizeLimit()).isEqualTo(43);
assertThat(sessionDecorator.getOverflowStrategy()).isEqualTo(OverflowStrategy.DROP);
}
}