oscerd opened a new pull request, #27721:
URL: https://github.com/apache/camel/pull/27721
# Description
The `chunk` component bound the message body, headers and variables into the
Chunk engine with `Chunk.putAll(...)` (`ChunkEndpoint.onExchange`). In the
Chunk API, a value set this way is re-parsed as template source and any Chunk
tags inside it are expanded; only `Chunk.setLiteral(...)` keeps a value
literal, and Camel never called it.
As a result a message value that happened to contain Chunk markup was
interpreted as template code rather than printed verbatim. For example, with a
template `This is the body {$body}` and a body of `{$headers.name}`, the output
was `This is the body World` (the inner tag expanded) instead of `This is the
body {$headers.name}`. This is inconsistent with Camel's other templating
components (`camel-freemarker`, `camel-velocity`, `camel-mustache`), which
substitute message data inertly.
# Fix
Before binding, message data is wrapped as literal Chunk snippets via
`Snippet.makeLiteralSnippet(...)`, recursively for nested header/variable maps.
Nested maps are copied preserving their kind through the configured
`HeadersMapFactory` (a case-insensitive headers map stays case-insensitive).
Only the route author's template file is parsed as template code; body, header
and variable values are rendered as-is.
The redundant second render (`newChunk.toString()` after `render(writer)`)
is also removed by reusing the already-rendered writer output.
# Tests
- New `ChunkValueExpansionTest`: a body value and a header value containing
Chunk markup are now printed literally, and normal template rendering still
resolves tags against the data.
- Full `camel-chunk` suite passes (16 tests), `-Psourcecheck` is green.
# Docs
Added a `camel-chunk` note to the 4.23 upgrade guide describing the changed
(now literal) handling of message data.
JIRA: https://issues.apache.org/jira/browse/CAMEL-25585
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]