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

   # Description
   
   [CAMEL-27327](https://issues.apache.org/jira/browse/CAMEL-27327) is the 
follow-up of CAMEL-27194 (#30514), from the review by @davsclaus.
   
   - **InputStream and StreamCache bodies.** `MongoDbProducer.getBsonListBody`, 
which reads the `List` body of `update` and `findOneAndUpdate` without the 
`CamelMongoDbCriteria` header and of `aggregate`, now also reads an 
`InputStream` or `StreamCache` body as text, as it already did for `byte[]`. 
Such a body, for example from platform-http or a file consumer with stream 
caching, failed with `InvalidPayloadException`.
   - **Surrounding whitespace.** `MongoDbBasicConverters.isArrayNotation` 
required `[` and `]` at the very start and end, so a JSON array ending with a 
newline, as in a file or a Kafka record, was not seen as an array. It now 
strips surrounding whitespace first. This applies to every `String` to `List` 
conversion of the component; the text that is parsed is unchanged.
   - **A body that is not a JSON array.** `update` and `findOneAndUpdate` 
without the criteria header now fail with their existing "body is not a List of 
Document objects with size = 2" error when the body does not convert to a 
`List`, for example a `String` holding a JSON object. Before, they failed with 
a `NullPointerException` (`saveObj` is null). `aggregate` keeps its fallback to 
a single `Bson` stage for such a body.
   - **Docs.** The update section says the body can be a JSON array of the two 
documents as text, and the aggregate section says the same for the pipeline, 
with a YAML example, so both are usable from YAML and XML routes. The catalog 
copy is updated.
   
   # Tests
   
   `MongoDbProducerListBodyTest`, with the mocked `MongoClient`:
   - an `InputStream` JSON array of the criteria and the update is applied with 
`updateOne`;
   - a `StreamCache` aggregate pipeline that ends with a newline is passed to 
`aggregate` as its 2 stages;
   - a `String` update body with a leading newline and spaces and a trailing 
CRLF is applied;
   - a `String` update body holding a JSON object fails with the `update` size 
error.
   
   Without the change, the first three tests fail with 
`InvalidPayloadException` (the whitespace one with a `NullPointerException`), 
and the last one with a `NullPointerException`. With it, the camel-mongodb unit 
tests pass (1128). The MongoDB container ITs were not run locally (no Docker).
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I built camel-mongodb with `install` (including code generation, 
`formatter:format` and `impsort:sort`); the only generated file that changed is 
the catalog copy of the component docs.
   
   _Claude Code on behalf of Ayush0612005_
   


-- 
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