davsclaus opened a new pull request, #30503: URL: https://github.com/apache/camel/pull/30503
## What [CAMEL-27299](https://issues.apache.org/jira/browse/CAMEL-27299): when `KameletProducer` applies the `binary` (`application-octet-stream`) output type of a **source** Kamelet, it keeps an `InputStream` body as it is and only sets `Content-Type: application/octet-stream`. ## Why Since CAMEL-27258 (#30453), the output data type of a source Kamelet is applied before the consuming route. With stream caching turned off, a source with the `binary` type gives a plain `InputStream`. Examples are aws-s3-source, google-storage-source, azure-storage-blob-source and ibm-cos-source, and the ftp, ftps and sftp sources with `streamDownload`. The `binary` type then read the whole object into memory. Before CAMEL-27258, the type was applied only after the consuming route, so that route got the stream. With this change it gets the stream again. This also lets the Kamelet catalog declare `binary` on ftp-, ftps- and sftp-source. ## Why not in the transformer itself The JIRA proposed keeping any `InputStream` in `ByteArrayDataTypeTransformer`. In the review of #30453, Croway asked for the opposite, for good reason: that transformer is global. It also serves `transformDataType`, route `inputType`/`outputType` and action Kamelets, where the steps after it got a `byte[]`. A stream that can be read only once would then be empty for the second step that reads it (`BinaryDataTypeOneShotStreamTest`). "This is what the route got before the output type ran" is only true for a source Kamelet. So the transformer is unchanged, and only the source path in `KameletProducer` keeps the stream: - A Kamelet counts as a source when its route does not start from `kamelet:source`. - The type counts as binary when the transformer that the registry resolves for it is a `ByteArrayDataTypeTransformer`. - Both are looked up once, with the output type. - An action Kamelet with `binary` still reads a plain stream into a `byte[]`. The 4.24 upgrade guide notes on the Kamelet output type and the binary data type say so. ## Tests - `KameletLoaderTest` (camel-yaml-dsl), stream caching off, with a stream that can be read only once: - `sourceKameletBinaryOutputTypeKeepsStream`: the consuming route gets the same stream with the `Content-Type`, and the stream is still unread. It fails without the fix. - `actionKameletBinaryOutputTypeReadsStream`: the steps after an action Kamelet still get a `byte[]`. - Run locally against a camel-kamelet built from this branch, in a scratch local repository: - `KameletLoaderTest`: 19 pass. - camel-kamelet: 172 pass, 2 skipped. _Claude Code on behalf of Claus Ibsen_ 🤖 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]
