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

Claus Ibsen commented on CAMEL-25937:
-------------------------------------

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

_Claude Code on behalf of davsclaus_

> camel-azure-storage-blob - an upload without a body fails with a 
> NullPointerException
> -------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25937
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25937
>             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: Minor
>             Fix For: 4.24.0
>
>
> {{BlobStreamAndLength.createBlobStreamAndLengthFromExchangeBody}} (main 
> 4065a7464c45, lines 60-66), which uploadBlockBlob, commitAppendBlob and 
> uploadBlockBlobChunked use to read the body, names the class of a body it 
> cannot read, and so fails with a NullPointerException when there is no body:
> {code:java}
> InputStream is = body instanceof InputStream inputStream
>         ? inputStream
>         : 
> exchange.getContext().getTypeConverter().tryConvertTo(InputStream.class, 
> exchange, body);
> if (is == null) {
>     throw new IllegalArgumentException("Unsupported blob type:" + 
> body.getClass().getName());
> }
> {code}
> {noformat}
> java.lang.NullPointerException: Cannot invoke "Object.getClass()" because 
> "body" is null
> {noformat}
> Checked on 4.24.0-SNAPSHOT against Azurite with uploadBlockBlob. A Map body 
> gets the intended {{IllegalArgumentException: Unsupported blob 
> type:java.util.LinkedHashMap}}.
> Also read in the code: commitAppendBlob and uploadPageBlob create their blob 
> before they read the body ({{BlobOperations}} lines 476-480 and 525-529, with 
> {{createAppendBlob}} and {{createPageBlob}}, which default to true), so an 
> upload without a body to a blob that does not exist yet leaves an empty blob 
> behind.
> *Proposed change*: fail with a clear error when there is no body, as 
> {{getMandatoryBody}} does ({{InvalidPayloadException}}), and read the body 
> before creating the blob.
> _Claude Code on behalf of davsclaus_



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

Reply via email to