Skip to content

Commit f9883d8

Browse files
committed
Polishing contribution
Closes gh-31970
1 parent 73ee86c commit f9883d8

File tree

6 files changed

+105
-204
lines changed

6 files changed

+105
-204
lines changed

framework-docs/modules/ROOT/pages/web/websocket/stomp/client.adoc

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ it handle ERROR frames in addition to the `handleException` callback for
105105
exceptions from the handling of messages and `handleTransportError` for
106106
transport-level errors including `ConnectionLostException`.
107107

108-
You can also use `setInboundMessageSizeLimit(limit)` and `setOutboundMessageSizeLimit(limit)`
109-
to limit the maximum size of inbound and outbound message size.
110-
When outbound message size exceeds `outboundMessageSizeLimit`, message is split into multiple incomplete frames.
111-
Then receiver buffers these incomplete frames and reassemble to complete message.
112-
When inbound message size exceeds `inboundMessageSizeLimit`, throw `StompConversionException`.
113-
The default value of in&outboundMessageSizeLimit is `64KB`.
108+
You can use the `inboundMessageSizeLimit` and `outboundMessageSizeLimit` properties of
109+
`WebSocketStompClient` to limit the maximum size of inbound and outbound WebSocket
110+
messages. When an outbound STOMP message exceeds the limit, it is split into partial frames,
111+
which the receiver would have to reassemble. By default, there is no size limit for outbound
112+
messages. When an inbound STOMP message size exceeds the configured limit, a
113+
`StompConversionException` is thrown. The default size limit for inbound messages is `64KB`.
114114

115115
[source,java,indent=0,subs="verbatim,quotes"]
116116
----

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,10 @@
2929
import org.springframework.util.MultiValueMap;
3030

3131
/**
32-
* An extension of {@link org.springframework.messaging.simp.stomp.StompDecoder}
33-
* that buffers content remaining in the input ByteBuffer after the parent
34-
* class has read all (complete) STOMP frames from it. The remaining content
35-
* represents an incomplete STOMP frame. When called repeatedly with additional
36-
* data, the decode method returns one or more messages or, if there is not
37-
* enough data still, continues to buffer.
32+
* Uses {@link org.springframework.messaging.simp.stomp.StompDecoder} to decode
33+
* a {@link ByteBuffer} to one or more STOMP message. If the message is incomplete,
34+
* unused content is buffered and combined with the next input buffer, or if there
35+
* is not enough data still, continues to buffer.
3836
*
3937
* <p>A single instance of this decoder can be invoked repeatedly to read all
4038
* messages from a single stream (e.g. WebSocket session) as long as decoding

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/SplittingStompEncoder.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
import org.springframework.util.Assert;
2525

2626
/**
27-
* An extension of {@link org.springframework.messaging.simp.stomp.StompEncoder}
28-
* that splits the STOMP message to multiple incomplete STOMP frames
29-
* when the encoded bytes length exceeds {@link SplittingStompEncoder#bufferSizeLimit}.
27+
* Uses {@link org.springframework.messaging.simp.stomp.StompEncoder} to encode
28+
* a message and splits it into parts no larger than the configured
29+
* {@link SplittingStompEncoder#bufferSizeLimit}.
3030
*
3131
* @author Injae Kim
32+
* @author Rossen Stoyanchev
3233
* @since 6.2
3334
* @see StompEncoder
3435
*/
@@ -38,18 +39,21 @@ public class SplittingStompEncoder {
3839

3940
private final int bufferSizeLimit;
4041

42+
4143
public SplittingStompEncoder(StompEncoder encoder, int bufferSizeLimit) {
4244
Assert.notNull(encoder, "StompEncoder is required");
4345
Assert.isTrue(bufferSizeLimit > 0, "Buffer size limit must be greater than 0");
4446
this.encoder = encoder;
4547
this.bufferSizeLimit = bufferSizeLimit;
4648
}
4749

50+
4851
/**
49-
* Encodes the given payload and headers into a list of one or more {@code byte[]}s.
50-
* @param headers the headers
51-
* @param payload the payload
52-
* @return the list of one or more encoded messages
52+
* Encode the given payload and headers to a STOMP frame, and split into a
53+
* list of parts based on the configured buffer size limit.
54+
* @param headers the STOMP message headers
55+
* @param payload the STOMP message payload
56+
* @return the parts of the encoded STOMP message
5357
*/
5458
public List<byte[]> encode(Map<String, Object> headers, byte[] payload) {
5559
byte[] result = this.encoder.encode(headers, payload);
@@ -65,4 +69,5 @@ public List<byte[]> encode(Map<String, Object> headers, byte[] payload) {
6569
}
6670
return frames;
6771
}
72+
6873
}

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompEncoder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,8 +83,8 @@ public byte[] encode(Message<byte[]> message) {
8383

8484
/**
8585
* Encodes the given payload and headers into a {@code byte[]}.
86-
* @param headers the headers
87-
* @param payload the payload
86+
* @param headers the STOMP message headers
87+
* @param payload the STOMP message payload
8888
* @return the encoded message
8989
*/
9090
public byte[] encode(Map<String, Object> headers, byte[] payload) {

0 commit comments

Comments
 (0)