Browse Source

Merge branch '6.2.x'

pull/35137/head
Sam Brannen 6 months ago
parent
commit
60b19278c0
  1. 18
      spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java
  2. 11
      spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java

18
spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java

@ -36,10 +36,10 @@ import org.springframework.web.socket.WebSocketSession; @@ -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 @@ -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 @@ -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).
*/

11
spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java

@ -215,4 +215,15 @@ class ConcurrentWebSocketSessionDecoratorTests { @@ -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);
}
}

Loading…
Cancel
Save