|
29 | 29 | import org.springframework.messaging.simp.SimpMessageType; |
30 | 30 | import org.springframework.messaging.support.MessageHeaderAccessor; |
31 | 31 | import org.springframework.util.ClassUtils; |
| 32 | +import org.springframework.util.CollectionUtils; |
32 | 33 | import org.springframework.util.MimeType; |
33 | 34 | import org.springframework.util.MimeTypeUtils; |
34 | 35 | import org.springframework.util.StringUtils; |
35 | 36 |
|
36 | 37 | /** |
37 | | - * A {@code MessageHeaderAccessor} to use when creating a {@code Message} from a |
38 | | - * decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame. |
| 38 | + * A {@code MessageHeaderAccessor} to use when creating a {@code Message} from |
| 39 | + * a decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame. |
39 | 40 | * |
40 | | - * <p>When created from STOMP frame content, the actual STOMP headers are stored |
41 | | - * in the native header sub-map managed by the parent class |
| 41 | + * <p>When created from STOMP frame content, the actual STOMP headers are |
| 42 | + * stored in the native header sub-map managed by the parent class |
42 | 43 | * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor} |
43 | | - * while the parent class |
44 | | - * {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor} manages |
45 | | - * common processing headers some of which are based on STOMP headers (e.g. |
46 | | - * destination, content-type, etc). |
| 44 | + * while the parent class {@link SimpMessageHeaderAccessor} manages common |
| 45 | + * processing headers some of which are based on STOMP headers |
| 46 | + * (e.g. destination, content-type, etc). |
47 | 47 | * |
48 | 48 | * <p>An instance of this class can also be created by wrapping an existing |
49 | 49 | * {@code Message}. That message may have been created with the more generic |
@@ -502,12 +502,8 @@ public static String getPasscode(Map<String, Object> headers) { |
502 | 502 | } |
503 | 503 |
|
504 | 504 | public static Integer getContentLength(Map<String, List<String>> nativeHeaders) { |
505 | | - if (nativeHeaders.containsKey(STOMP_CONTENT_LENGTH_HEADER)) { |
506 | | - List<String> values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER); |
507 | | - String value = (values != null ? values.get(0) : null); |
508 | | - return Integer.valueOf(value); |
509 | | - } |
510 | | - return null; |
| 505 | + List<String> values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER); |
| 506 | + return (!CollectionUtils.isEmpty(values) ? Integer.valueOf(values.get(0)) : null); |
511 | 507 | } |
512 | 508 |
|
513 | 509 |
|
|
0 commit comments