Andrea Cosentino created CAMEL-24792:
----------------------------------------
Summary: camel-aws2-ddb: setHeaderIfNotPresent in
Ddb2JsonDataTypeTransformer always overwrites the header
Key: CAMEL-24792
URL: https://issues.apache.org/jira/browse/CAMEL-24792
Project: Camel
Issue Type: Bug
Components: camel-aws2
Reporter: Andrea Cosentino
h3. Summary
{{Ddb2JsonDataTypeTransformer.setHeaderIfNotPresent(String, Object, Message)}}
does not do what its name says - the body is an unconditional
{{message.setHeader(headerName, value)}} with no presence check:
{code:java}
private void setHeaderIfNotPresent(String headerName, Object value, Message
message) {
message.setHeader(headerName, value);
}
{code}
It has been this way since the method was introduced in 2023.
h3. Effect
The three call sites all pass {{Ddb2Constants.RETURN_VALUES}}, so a
{{CamelAwsDdbReturnValues}} header set by the route before the transformer runs
is silently replaced by the transformer default ({{ALL_OLD}} for
{{PutItem}}/{{DeleteItem}}, {{ALL_NEW}} for {{UpdateItem}}). There is currently
no way to choose a different {{ReturnValue}} through the transformer.
h3. Proposal
Add the missing presence check so an explicitly set header wins, matching the
method name and the evident intent. Add a unit test covering both branches
(header absent -> default applied; header present -> preserved), and note the
behaviour change in the 4.23 upgrade guide.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)