davsclaus opened a new pull request, #30454:
URL: https://github.com/apache/camel/pull/30454

   [CAMEL-27259](https://issues.apache.org/jira/browse/CAMEL-27259)
   
   The `insert` operation of `MongoDbProducer` treated any array body as a 
batch and cast it to `Object[]`. So a `byte[]` body failed with 
`ClassCastException: class [B cannot be cast to class [Ljava.lang.Object;`. 
JSON text from a Kafka consumer, or from a source with the `binary` data type 
(which now reaches the consuming route, CAMEL-27258), is such a body. This also 
breaks the camel-kamelets `mongodb-sink` for such input.
   
   Only an `Object[]` is now a batch. A `byte[]` goes the way a String does: 
the existing `byte[]` to `Document` converter turns it into one document.
   
   ### Tests
   New `MongoDbProducerInsertBodyTest`, with a mocked `MongoClient` like 
`MongoDbProducerCursorTest`:
   - a `byte[]` JSON body is inserted with `insertOne` as one document, with 
its fields;
   - an `Object[]` of Documents is still a batch (`insertMany`).
   
   The `byte[]` test fails with the ClassCastException without the fix. 
`MongoDbProducer*Test`: 5 of 5 pass.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to