Skip to content

Question about MessageHeaders.REPLY_CHANNEL.endsWith(headerName) usage in MessageHeaderAccessor#verifyType #34881

Closed as not planned
@NineSu

Description

@NineSu

Hi Spring team,

While reading the source code of org.springframework.messaging.support.MessageHeaderAccessor, I noticed something that seems potentially unintended in the verifyType method:

protected void verifyType(@Nullable String headerName, @Nullable Object headerValue) {
	if (headerName != null && headerValue != null) {
		if (MessageHeaders.ERROR_CHANNEL.equals(headerName) ||
				MessageHeaders.REPLY_CHANNEL.endsWith(headerName)) {
			if (!(headerValue instanceof MessageChannel || headerValue instanceof String)) {
				throw new IllegalArgumentException(
						"'" + headerName + "' header value must be a MessageChannel or String");
			}
		}
	}
}

My question is about the use of MessageHeaders.REPLY_CHANNEL.endsWith(headerName) — is this intended to be endsWith, or should it be equals, similar to how ERROR_CHANNEL is compared? Using endsWith might lead to false positives when the header name is a suffix of "replyChannel".

Could you please clarify if this is intentional or if it might be a bug?

Thanks for your great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: messagingIssues in messaging modules (jms, messaging)status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions