diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java index ac4fbbbb7da..e31957e33f1 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java @@ -102,7 +102,7 @@ public class BufferingStompDecoder { this.chunks.add(newBuffer); checkBufferLimits(); - if (getExpectedContentLength() != null && getBufferSize() < this.expectedContentLength) { + if (this.expectedContentLength != null && getBufferSize() < this.expectedContentLength) { return Collections.>emptyList(); } @@ -139,12 +139,12 @@ public class BufferingStompDecoder { if (this.expectedContentLength != null) { if (this.expectedContentLength > this.bufferSizeLimit) { throw new StompConversionException( - "'content-length' header value " + this.expectedContentLength + - " exceeds configured message buffer size limit " + this.bufferSizeLimit); + "STOMP 'content-length' header value " + this.expectedContentLength + + " exceeds configured buffer size limit " + this.bufferSizeLimit); } } if (getBufferSize() > this.bufferSizeLimit) { - throw new StompConversionException("The configured stomp frame buffer size limit of " + + throw new StompConversionException("The configured STOMP buffer size limit of " + this.bufferSizeLimit + " bytes has been exceeded"); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java index dc467a9f7b6..7d2231cac1d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java @@ -29,21 +29,21 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.messaging.support.MessageHeaderAccessor; import org.springframework.util.ClassUtils; +import org.springframework.util.CollectionUtils; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; import org.springframework.util.StringUtils; /** - * A {@code MessageHeaderAccessor} to use when creating a {@code Message} from a - * decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame. + * A {@code MessageHeaderAccessor} to use when creating a {@code Message} from + * a decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame. * - *

When created from STOMP frame content, the actual STOMP headers are stored - * in the native header sub-map managed by the parent class + *

When created from STOMP frame content, the actual STOMP headers are + * stored in the native header sub-map managed by the parent class * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor} - * while the parent class - * {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor} manages - * common processing headers some of which are based on STOMP headers (e.g. - * destination, content-type, etc). + * while the parent class {@link SimpMessageHeaderAccessor} manages common + * processing headers some of which are based on STOMP headers + * (e.g. destination, content-type, etc). * *

An instance of this class can also be created by wrapping an existing * {@code Message}. That message may have been created with the more generic @@ -502,12 +502,8 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor { } public static Integer getContentLength(Map> nativeHeaders) { - if (nativeHeaders.containsKey(STOMP_CONTENT_LENGTH_HEADER)) { - List values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER); - String value = (values != null ? values.get(0) : null); - return Integer.valueOf(value); - } - return null; + List values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER); + return (!CollectionUtils.isEmpty(values) ? Integer.valueOf(values.get(0)) : null); }