davsclaus opened a new pull request, #30487:
URL: https://github.com/apache/camel/pull/30487

   [CAMEL-27290](https://issues.apache.org/jira/browse/CAMEL-27290)
   
   ## What
   
   With the Kamelet EIP (`- kamelet: name: x-action`), the output data type of 
an action Kamelet was applied **after** the steps that follow the EIP. The YAML 
loader made `spec.dataTypes.out.default` the output type of the template route, 
which `ContractAdvice` applies when that route completes, but `kamelet:sink` 
continues the EIP inside the template route. With `to: kamelet:x-action` the 
steps came after the route had completed, so they got the type.
   
   Repro with an action whose out default is `application-octet-stream`:
   - EIP form: the step after it logs `class=java.lang.String ct=`, and then 
`ByteArrayDataTypeTransformer` runs.
   - `to:` form: the step after it logs `class=[B ct=application/octet-stream`.
   
   ## Fix
   
   CAMEL-27258 (#30453) already moved the out type of a **source** Kamelet to 
the route property `kameletSourceOutputType`, which `KameletProducer` applies 
at `kamelet:sink`. The loader now does this for every Kamelet, under the route 
property `kameletOutputType` (renamed, as it is no longer for sources only; 
both are unreleased). So the type is applied once, at `kamelet:sink`, with the 
EIP and with `to:`. The route has no output type any more, so the `to:` form 
does not transform twice.
   
   The producer also sets the type as the data type of the message, as 
`ContractAdvice` did, so the input data type of the next Kamelet is converted 
from it.
   
   Behaviour change, in the upgrade guide (the CAMEL-27258 entry is widened): a 
message that does not reach `kamelet:sink`, such as one an action Kamelet 
filters out, no longer gets the type.
   
   ## Tests
   
   `KameletLoaderTest`:
   - the EIP form gives the steps after it a `byte[]` with 
`application/octet-stream`, and a `Map` set afterwards no longer fails the 
exchange (fails without the fix);
   - the `to:` form still gets the type;
   - a counting transformer shows the type is applied exactly once in both 
forms (the EIP case fails without the fix).
   
   camel-kamelet (172) and the Kamelet/Pipe tests of camel-yaml-dsl (43) pass.
   
   Related: #30486 (CAMEL-27289) fixes the transformer lookup when the next 
Kamelet's input type is not loaded yet.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 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]

Reply via email to