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

   ## What
   
   `ElasticsearchBulkRequestAggregationStrategy` and its OpenSearch twin 
`OpensearchBulkRequestAggregationStrategy` merge several `BulkOperation[]` 
messages into a single `BulkRequest` (the documented bulk-aggregation pattern, 
used with the Aggregate EIP). Both built the merged request, stored it on 
`newExchange`, and then **`return oldExchange;`**.
   
   On the first message of an aggregation group `oldExchange == null`, so the 
strategy returned `null`. `AggregateProcessor` rejects a null return:
   
   ```
   AggregationStrategy ... returned null which is not allowed
   ```
   
   So the **very first exchange of every group failed**, and even past the 
first call the returned exchange never carried the merged `BulkRequest`. The 
strategy was effectively unusable. It stayed latent because neither component 
had a unit test for it.
   
   ## Fix
   
   - Return `newExchange` (which already holds the merged `BulkRequest`) in 
both strategies.
   - Add the already-aggregated operations **before** the new ones, so the 
merged request preserves insertion order 
(`BulkRequest.Builder.operations(List)` is additive).
   - Add unit tests covering the first-call and subsequent-call paths in both 
`camel-elasticsearch` and `camel-opensearch` (previously untested).
   
   ## Notes
   
   - Logic-only change; no public API, `@UriParam`/`@Metadata`, or 
generated-catalog change.
   - Affects both components identically — bundled since the fix and reasoning 
are the same.
   - Backport candidate for `camel-4.22.x` and `camel-4.18.x`.
   
   _Generated by Claude Code on behalf of Andrea Cosentino (@oscerd)._
   
   🤖 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