Polishing

This commit is contained in:
Sam Brannen
2024-03-12 17:34:02 +01:00
parent 3b87c87a33
commit 7211db9262
8 changed files with 173 additions and 178 deletions

View File

@@ -24,9 +24,9 @@ import java.util.Map;
import org.springframework.util.Assert;
/**
* Uses {@link org.springframework.messaging.simp.stomp.StompEncoder} to encode
* a message and splits it into parts no larger than the configured
* {@link SplittingStompEncoder#bufferSizeLimit}.
* Uses a {@link StompEncoder} to encode a message and splits it into parts no
* larger than the configured
* {@linkplain #SplittingStompEncoder(StompEncoder, int) buffer size limit}.
*
* @author Injae Kim
* @author Rossen Stoyanchev
@@ -40,6 +40,11 @@ public class SplittingStompEncoder {
private final int bufferSizeLimit;
/**
* Create a new {@code SplittingStompEncoder}.
* @param encoder the {@link StompEncoder} to use
* @param bufferSizeLimit the buffer size limit
*/
public SplittingStompEncoder(StompEncoder encoder, int bufferSizeLimit) {
Assert.notNull(encoder, "StompEncoder is required");
Assert.isTrue(bufferSizeLimit > 0, "Buffer size limit must be greater than 0");
@@ -49,7 +54,7 @@ public class SplittingStompEncoder {
/**
* Encode the given payload and headers to a STOMP frame, and split into a
* Encode the given payload and headers to a STOMP frame, and split it into a
* list of parts based on the configured buffer size limit.
* @param headers the STOMP message headers
* @param payload the STOMP message payload

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,10 +78,10 @@ public class StompDecoder {
* Decodes one or more STOMP frames from the given {@code ByteBuffer} into a
* list of {@link Message Messages}. If the input buffer contains partial STOMP frame
* content, or additional content with a partial STOMP frame, the buffer is
* reset and an empty list is returned.
* reset, and an empty list is returned.
* @param byteBuffer the buffer to decode the STOMP frame from
* @return the decoded messages, or an empty list if none
* @throws StompConversionException raised in case of decoding issues
* @throws StompConversionException in case of decoding issues
*/
public List<Message<byte[]>> decode(ByteBuffer byteBuffer) {
return decode(byteBuffer, null);
@@ -93,18 +93,18 @@ public class StompDecoder {
* <p>If the given ByteBuffer contains only partial STOMP frame content and no
* complete STOMP frames, an empty list is returned, and the buffer is reset
* to where it was.
* <p>If the buffer contains one or more STOMP frames, those are returned and
* the buffer reset to point to the beginning of the unused partial content.
* <p>The output partialMessageHeaders map is used to store successfully parsed
* <p>If the buffer contains one or more STOMP frames, those are returned, and
* the buffer is reset to point to the beginning of the unused partial content.
* <p>The {@code partialMessageHeaders} map is used to store successfully parsed
* headers in case of partial content. The caller can then check if a
* "content-length" header was read, which helps to determine how much more
* content is needed before the next attempt to decode.
* @param byteBuffer the buffer to decode the STOMP frame from
* @param partialMessageHeaders an empty output map that will store the last
* successfully parsed partialMessageHeaders in case of partial message content
* successfully parsed partial message headers in case of partial message content
* in cases where the partial buffer ended with a partial STOMP frame
* @return the decoded messages, or an empty list if none
* @throws StompConversionException raised in case of decoding issues
* @throws StompConversionException in case of decoding issues
*/
public List<Message<byte[]>> decode(ByteBuffer byteBuffer,
@Nullable MultiValueMap<String, String> partialMessageHeaders) {
@@ -127,7 +127,7 @@ public class StompDecoder {
}
/**
* Decode a single STOMP frame from the given {@code buffer} into a {@link Message}.
* Decode a single STOMP frame from the given {@code byteBuffer} into a {@link Message}.
*/
@Nullable
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) {