[backport camel-4.22.x] CAMEL-24409: keep binary bodies intact in rest client request validation - #26070
Conversation
…t client request validation Checking that a required body is present read the body as a String and wrote that String back onto the message, which corrupted binary payloads such as application/octet-stream. extractBodyAsString already leaves the body as a re-readable StreamCache, so the write back was not needed to keep the body readable, only to lose the bytes. (cherry picked from commit cfa4c36) Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 556 tested, 28 compile-only — current: 555 all testedMaveniverse Scalpel detected 584 affected modules (current approach: 555).
|
…o 4.22 and 4.18 guides (#26072) The binary-body fix (PR #26024) is backported to camel-4.22.x (PR #26070) and camel-4.18.x (PR #26071). Per the backport upgrade-guide policy, main's version-specific guides are the canonical history, so add the matching note to the 4.22 and 4.18 upgrade guides on main. Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Backport of #26024
Cherry-pick of #26024 onto
camel-4.22.x.Original PR: #26024 - CAMEL-24409: keep binary bodies intact in rest client request validation
Original author: @chala2001
Target branch:
camel-4.22.xSummary
With
clientRequestValidationenabled and a REST service that declares a required body, binary payloads (e.g.application/octet-stream) were corrupted:DefaultRestClientRequestValidatorread the body as aStringand wrote it back, replacing bytes that are not valid UTF-8 withEF BF BD(the Unicode replacement character).MessageHelper.extractBodyAsStringalready leaves the body as a re-readableStreamCache, so the write-back was unnecessary. Removing it keeps the required-body check while leaving the payload untouched.Backport notes
DefaultRestClientRequestValidator) and theRestJettyRequiredBodyTestcherry-picked cleanly.camel-4x-upgrade-guide-4_23.adoc(does not exist on this line) tocamel-4x-upgrade-guide-4_22.adoc, matching the release line this fix ships in.camel-supportbuilds andRestJettyRequiredBodyTestpasses (4/4).Claude Code on behalf of davsclaus