[ 
https://issues.apache.org/jira/browse/CAMEL-26177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-26177.
---------------------------------
    Resolution: Fixed

Fixed by https://github.com/apache/camel/pull/29006 (merged to main as 
0f11a4a21c33cb43e4f5411783ccbc0dc8c6ad0d).

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-dhis2 - post/put send bytes as base64 and a File as its path, and a 
> leftover body is sent on delete
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26177
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26177
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-dhis2
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of dhis2 (CAMEL-24961, PR #28412).
> h4. 1. post, put and delete send bytes as base64 and a File as its path, and 
> an InputStream fails
> {{Dhis2Producer.findMethod}} (main 2a465aa4814c, lines 36-37) passes the body 
> as is as the {{resource}} argument, and {{Dhis2Post.resource}} (line 48, same 
> in {{Dhis2Put}} and {{Dhis2Delete}}) hands it to the DHIS2 client, which 
> writes it with Jackson. So a {{byte[]}} with JSON is sent as a base64 JSON 
> string and a {{java.io.File}} as its path string, with no error, and an 
> {{InputStream}} fails in Jackson. Checked on 4.24.0-SNAPSHOT with a JDK HTTP 
> server as the DHIS2 API.
> Proposed: send text, byte array, stream and file bodies as the raw JSON 
> payload instead of serializing them with Jackson.
> h4. 2. A leftover body is sent as the payload of delete/resource
> {{Dhis2Producer.findMethod}} (main 2a465aa4814c, lines 36-37) sets 
> {{resource}} from the body for every call, so for {{delete/resource}} (whose 
> {{resource}} is optional) any body left by an earlier step is sent as the 
> DELETE payload. Checked on 4.24.0-SNAPSHOT with the local server.
> Proposed: take the body as the resource only for the methods that need one 
> ({{post}} and {{put}}), or only through {{inBody=resource}}.
> h4. 3. The get/collection consumer emits one message with an Iterator body
> {{Dhis2Get.collection}} (main 2a465aa4814c, line 80) returns an 
> {{Iterator<Dhis2Resource>}}, and {{ApiConsumerHelper.getResultsProcessed}} 
> (camel-support, lines 100-112) splits Lists, Iterables and arrays but not an 
> Iterator, so the consumer sends one message whose body is the Iterator 
> instead of one message per resource. Checked on 4.24.0-SNAPSHOT with the 
> local server.
> Proposed: split an Iterator too (in {{ApiConsumerHelper}}, or by wrapping it 
> in {{Dhis2Consumer.splitResult}}).
> _Claude Code on behalf of davsclaus_



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

Reply via email to