Skip to content

Commit f207c0e

Browse files
committed
Polish contribution
See gh-34949
1 parent bbf61c7 commit f207c0e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java

Lines changed: 1 addition & 1 deletion
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-2025 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.

spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -239,21 +239,22 @@ void buildMultipleMessages() {
239239
assertThat(message3.getHeaders().get("foo")).isEqualTo("bar3");
240240
}
241241

242-
@Test
243-
void buildReplyChannelHeaderMessage() {
242+
@Test // gh-34949
243+
void buildMessageWithReplyChannelHeader() {
244244
MessageHeaderAccessor headerAccessor = new MessageHeaderAccessor();
245245
MessageBuilder<?> messageBuilder = MessageBuilder.withPayload("payload").setHeaders(headerAccessor);
246246

247-
headerAccessor.setHeader("replyChannel", "foo");
247+
headerAccessor.setHeader(MessageHeaders.REPLY_CHANNEL, "foo");
248248
Message<?> message1 = messageBuilder.build();
249+
assertThat(message1.getHeaders().get(MessageHeaders.REPLY_CHANNEL)).isEqualTo("foo");
249250

250251
headerAccessor.setHeader("hannel", 0);
251252
Message<?> message2 = messageBuilder.build();
252-
253-
assertThat(message1.getHeaders().get("replyChannel")).isEqualTo("foo");
254253
assertThat(message2.getHeaders().get("hannel")).isEqualTo(0);
255254

256-
assertThatIllegalArgumentException().isThrownBy(() -> headerAccessor.setHeader("replyChannel", 0));
255+
assertThatIllegalArgumentException()
256+
.isThrownBy(() -> headerAccessor.setHeader(MessageHeaders.REPLY_CHANNEL, 0))
257+
.withMessage("'%s' header value must be a MessageChannel or String", MessageHeaders.REPLY_CHANNEL);
257258
}
258259

259260
}

0 commit comments

Comments
 (0)