Fix default charset in Undertow consumer when Content-Type omits charset#22471
Fix default charset in Undertow consumer when Content-Type omits charset#22471Croway wants to merge 1 commit intoapache:mainfrom
Conversation
… no charset Undertow's getRequestCharset() defaults to ISO-8859-1 when no charset is specified in the Content-Type header. This causes UTF-8 encoded request bodies to be decoded incorrectly. Only set the exchange charset property when explicitly specified, letting Camel default to UTF-8.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Nice fix, thanks @Croway! 👍
The change correctly aligns UndertowConsumer with DefaultHttpBinding's behavior — only setting the charset property when explicitly specified in the Content-Type header, rather than relying on Undertow's getRequestCharset() which defaults to ISO-8859-1.
The test coverage is good — sending non-ASCII UTF-8 characters with Content-Type: application/json (no charset) is exactly the right scenario to validate.
One minor note: there's no JIRA ticket linked. For changelog traceability a JIRA issue is typically preferred even for bug fixes, but not blocking.
LGTM ✅
Claude Code on behalf of Guillaume Nodet
|


Summary
getRequestCharset()defaults to ISO-8859-1 when no charset is specified in theContent-Typeheader, causing UTF-8 encoded request bodies (e.g.application/json) to be decoded incorrectlyDefaultHttpBindingContent-Type: application/json(no charset)Test plan
RestUndertowHttpPostJsonPojoCharsetTestfails before fix, passes after