Claus Ibsen created CAMEL-27299:
-----------------------------------

             Summary: 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
             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)

Reply via email to