Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NineSu opened this issue May 12, 2025 · 3 comments · May be fixed by #34949
Closed
Labels
in: messaging Issues in messaging modules (jms, messaging) status: superseded An issue that has been superseded by another

Comments

@NineSu
Copy link

NineSu commented May 12, 2025

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!

@NineSu

This comment has been minimized.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 12, 2025
remeio added a commit to remeio/spring-framework that referenced this issue May 26, 2025
@sbrannen sbrannen added the in: messaging Issues in messaging modules (jms, messaging) label May 28, 2025
@rstoyanchev
Copy link
Contributor

Thanks for spotting this very old issue that can be traced all the way back to commit 059aef in Spring Integration. It appears to be an oversight as it would only apply to header names that are a subset of "replyChannel", and that doesn't make much sense.

@rstoyanchev
Copy link
Contributor

Superseded by #34949.

@rstoyanchev rstoyanchev closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2025
@rstoyanchev rstoyanchev added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants