Skip to content

[backport camel-4.18.x] CAMEL-25085: camel-support - RestBindingAdvice takes the response Content-Type from produces - #27288

Merged
Croway merged 1 commit into
apache:camel-4.18.xfrom
Croway:backport-camel-4.18.x-CAMEL-25085-rest-binding-produces
Oct 2, 2026
Merged

Croway merged 1 commit into
apache:camel-4.18.xfrom
Croway:backport-camel-4.18.x-CAMEL-25085-rest-binding-produces

Conversation

@Croway

@Croway Croway commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Backport of #26986 (CAMEL-25085) to camel-4.18.x.

https://issues.apache.org/jira/browse/CAMEL-25085

Under json or xml binding, a response without a Content-Type header again takes it from the produces of the rest verb, as before 4.18.4 (CAMEL-24001). A verb that produces("application/octet-stream") under bindingMode(json) no longer answers an empty 500, and a text/plain verb called with a json Accept header answers plain text again.

Cherry-pick of 4767770. The code hunk and the camel-core test applied without conflicts. Two adaptations compared to the original PR:

  • VertxPlatformHttpRestBindingProducesTest calls context.start() instead of VertxPlatformHttpEngineTest.startCamelContext(context), because that helper does not exist on 4.18.x (the 4.18.x createCamelContext() already sets the RestAssured port). Test-only, one line.
  • Upgrade guides: the note is kept in camel-4x-upgrade-guide-4_18.adoc under the existing "Upgrading from 4.18.4 to 4.18.5" section; the 4_22 and 4_23 guide edits are dropped as those files do not exist on this branch.

Verified locally on this branch: FromRestBindingProducesContentTypeTest fails 2 of 5 without the fix (octet-stream and text/plain get application/json) and passes with it; VertxPlatformHttpRestBindingProducesTest passes.

Claude Code on behalf of Croway

🤖 Generated with Claude Code

…tent-Type from produces (apache#26986)

Under json or xml binding, a response without a Content-Type header again
takes it from the produces of the rest verb, as before Camel 4.18.4 and
4.22.0 (CAMEL-24001). Those releases used application/json (or xml)
whenever the binding mode allowed it and marshalled the body, so a verb
producing text/plain answered with a json-quoted body and a binary body
failed. When produces lists several media types, the first json (or xml)
type is used, otherwise the first one. Wildcards such as */* are skipped.

(cherry picked from commit 4767770)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Croway
Croway requested review from davsclaus and oscerd October 2, 2026 13:43
@Croway
Croway merged commit 724d1da into apache:camel-4.18.x Oct 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants