[
https://issues.apache.org/jira/browse/CAMEL-27299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148223#comment-18148223
]
Claus Ibsen commented on CAMEL-27299:
-------------------------------------
Fixed in https://github.com/apache/camel/pull/30503 with a narrower scope than
proposed. The binary data type transformer itself stays as it is: in
transformDataType, inputType/outputType and action Kamelets it still reads a
plain InputStream into a byte[], because the steps after it got a byte[]
before, and a stream that can be read only once would be empty for the second
reader (review of #30453, BinaryDataTypeOneShotStreamTest). Only
KameletProducer, when it applies the binary output type of a source Kamelet,
keeps an InputStream body and sets Content-Type. That is what the consuming
route got before CAMEL-27258.
_Claude Code on behalf of Claus Ibsen_
> camel-core - the binary data type keeps an InputStream body, and does not
> read it into a byte array
> ---------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27299
> URL: https://issues.apache.org/jira/browse/CAMEL-27299
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> {{ByteArrayDataTypeTransformer}} ({{application-octet-stream}}, alias
> {{binary}}) keeps a {{StreamCache}}, {{File}}, {{Path}} or {{WrappedFile}}
> body (CAMEL-27258, CAMEL-27267), but reads any other body into a {{byte[]}},
> also a plain {{InputStream}}.
> Since CAMEL-27258, the output data type of a source Kamelet is applied before
> the consuming route. Many source Kamelets of the catalog declare {{binary}}
> (aws-s3-source, google-storage-source, azure-storage-blob-source,
> ibm-cos-source and more). With stream caching turned off, their component
> gives a plain {{InputStream}}, and the {{binary}} type now reads the whole
> object into memory, where before the route got the stream. For large objects
> that can exhaust the heap. It also stops the catalog from declaring
> {{binary}} on ftp-, ftps- and sftp-source, whose large-file modes
> ({{streamDownload}}) give a plain {{InputStream}}.
> Proposal: {{ByteArrayDataTypeTransformer}} also keeps an {{InputStream}} body
> as it is, and only sets {{Content-Type: application/octet-stream}}. A plain
> {{InputStream}} can be read only once, but that is what the route got before
> the output type was applied, so nothing changes for it; a route that needs
> bytes converts the body, as it did before.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)