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

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

Fixed by https://github.com/apache/camel/pull/28999 (merged to main as 
77a330bb8c839a12f6dd81739515318827b7e2e5).

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-stitch - a request Map with key_names as a String fails with 
> ClassCastException, and an Integer sequence fails the Long cast
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26174
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26174
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of stitch (CAMEL-24961, PR #28412).
> h4. 1. A request Map with key_names as a String fails with ClassCastException
> {{StitchRequestBody.fromMap}} (main 2a465aa4814c, line 80) casts 
> {{key_names}} to a {{Collection}}, so a Map body with {{"key_names": "id"}} 
> fails with a ClassCastException. Both Map examples in the doc did this (fixed 
> in the PR to use a List). Checked on 4.24.0-SNAPSHOT with a JDK HTTP server 
> behind {{StitchClientImpl}}.
> Proposed: accept a String (one key name, or comma separated names) as well as 
> a Collection.
> h4. 2. A message Map with an Integer sequence fails with "Cannot cast Integer 
> to Long"
> {{StitchMessage.fromMap}} (main 2a465aa4814c, line 58) casts {{sequence}} to 
> {{Long}}. A Map read from JSON or YAML, or written in Groovy, has a small 
> number as an {{Integer}}, so it fails with "Cannot cast java.lang.Integer to 
> java.lang.Long". Checked on 4.24.0-SNAPSHOT with the local server.
> Proposed: accept any {{Number}} and use {{longValue()}}.
> h4. 3. A 200 response with an empty body leaves the input body and sets no 
> headers
> {{StitchClientImpl.generateStitchResponse}} (main 2a465aa4814c, line 87) maps 
> {{bufMono.asString()}}, which emits nothing for an empty body, so no 
> {{StitchResponse}} is produced and {{StitchProducer.setDataOnExchange}} (line 
> 64) never runs: the exchange completes with the request body unchanged and 
> without the {{CamelStitchCode}}, {{CamelStitchStatus}} and 
> {{CamelStitchHeaders}} headers. Checked on 4.24.0-SNAPSHOT with the local 
> server.
> Proposed: emit a response with an empty message when the body is empty (for 
> example {{defaultIfEmpty}}), so the code and headers are set.
> _Claude Code on behalf of davsclaus_



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

Reply via email to