[ 
https://issues.apache.org/jira/browse/CAMEL-25933?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18131131#comment-18131131
 ] 

Claus Ibsen commented on CAMEL-25933:
-------------------------------------

Fixed in PR https://github.com/apache/camel/pull/28372

_Claude Code on behalf of davsclaus_

> camel-azure-storage-blob - getBlob writes the blob into a File or GenericFile 
> body, so after a file consumer it overwrites the file that was consumed
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25933
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25933
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-azure
>    Affects Versions: 4.18.0, 4.22.0, 4.23.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> The getBlob operation writes the blob into the body when the body converts to 
> an {{OutputStream}}, and gives a stream of the blob only when it does not 
> ({{BlobOperations.getBlob}}, main 4065a7464c45, lines 105 and 111):
> {code:java}
> final OutputStream outputStream = ObjectHelper.isEmpty(message) ? null : 
> message.getBody(OutputStream.class);
> ...
> if (outputStream == null) {
>     // Then we create an input stream
> {code}
> The documentation says it so for an OutputStream body: "Returns an 
> InputStream, or writes to an OutputStream if one is set in the body" 
> ({{azure-storage-blob-operations.adoc}} line 85). But a {{java.io.File}} and 
> a {{java.nio.file.Path}} convert to an OutputStream too, as a new 
> {{FileOutputStream}} that empties the file 
> ({{IOConverter.toOutputStream(File)}} and {{toOutputStream(Path)}}, lines 98 
> and 103), and so does the GenericFile of the file consumer, through the 
> fallback converter of camel-file. So a route that gets a blob when a file 
> arrives:
> {code:yaml}
> - route:
>     from:
>       uri: file:/tmp/blobtest?fileName=local.txt&noop=true
>       steps:
>         - to: 
> azure-storage-blob:devstoreaccount1/bodytypes?operation=getBlob&blobName=hello.txt
>         - log: "${body.getClass().getName()}"
> {code}
> replaces the content of {{/tmp/blobtest/local.txt}} with the blob, although 
> the consumer has {{noop=true}}, and the body after getBlob is a closed 
> {{java.io.BufferedOutputStream}} instead of the content. Checked against 
> Azurite on 4.24.0-SNAPSHOT: the file held "local file content" before the 
> route, and "Hello Camel", the content of the blob, after it.
> The code is the same since 3.9.0 at least, when CAMEL-16321 moved the 
> component to camel-azure.
> *Proposed change*: write into the body only when it is an {{OutputStream}} 
> ({{instanceof}}), not when it converts to one, and give the stream of the 
> blob otherwise.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to