davsclaus opened a new pull request, #28802: URL: https://github.com/apache/camel/pull/28802
Fixes [CAMEL-25050](https://issues.apache.org/jira/browse/CAMEL-25050). With `variableReceive` (`toV`, `enrich`, `pollEnrich`, `fromV`, ...) the received body goes into the variable, and each received header into a header variable `header:<name>.<key>`. For a route variable `route:resp` in route `rs`, the name in the route repository is `rs:resp`, so the header key became `header:rs:resp.status`. `RouteVariableRepository` splits at the first colon, so all header variables of all routes ended up in one route with the id `header`. The same happened for group variables. As a result, `route:header:resp.status` returned null (it was read as variable `resp.status` of a route named `header`), only the internal name `route:header:rs:resp.status` worked, and `removeRoute("rs")` left the header variables behind. **What changes:** - `ExchangeHelper.setVariableFromMessageBodyAndHeaders` stores the header variables of a route or group variable as `rs:header:resp.status` / `myGroup:header:resp.status`, so they live next to the variable in its own route or group. The removal of the old header variables (CAMEL-25035) now only scans that route's or group's map. - `ExchangeHelper.resolveVariableRepositoryName` adds the current route id to `route:header:resp.status`, as it already does for `route:resp`. - So these names work: `route:header:resp.status` (current route), `route:rs:header:resp.status` and `group:myGroup:header:resp.status`. Removing a route removes the header variables of its variables, and `GroupVariableRepository.getGroupIds()` no longer lists a group `header`. - `variables.adoc` has a table of the header variable names for route and group variables, and the 4.24 upgrade guide lists the old and new names. **Compatibility:** `route:header:rs:resp.status` and `group:header:myGroup:resp.status` no longer find the header; in this repository only `ToVariableReceiveHeadersTest` used them. Inside a route, `route:header:x` now means a header variable of the current route, not the variable `x` of a route with the id `header`. Global variables (`global:header:resp.status`) and exchange variables are unchanged. The optional `header:resp` map lookup from the ticket is not part of this PR. **Tests:** `ToVariableReceiveHeadersTest` reads the route and group header variables with the new names (the route reads them with `${variable.route:header:resp.status}`), checks that nothing is stored under the id `header` and that `getGroupIds()` has only the real groups, and a new test checks that `removeRoute` removes the header variables. The variable, enrich, `toV`/`fromV` and `ExchangeHelper` tests of camel-core pass (242 + 66). _Claude Code on behalf of davsclaus (Claus Ibsen)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- 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]
