davsclaus opened a new pull request, #28312: URL: https://github.com/apache/camel/pull/28312
Fixes [CAMEL-26026](https://issues.apache.org/jira/browse/CAMEL-26026). The solr producer picked the operation from the type of the body before it looked at the `CamelSolrOperation` header and the `operation` option: a Map, a File or a Collection that is not all Strings ran an INSERT, and a Collection of Strings ran a DELETE by id. So the operation of a route depended on the shape of its data: with `operation=INSERT` a List of Strings deleted the documents with those ids, and with `operation=SEARCH` a Map was inserted. A `CamelSolrOperation` value that is not an operation did not fail either. **Changes** (`SolrProducer.resolveSolrOperation`) - A body that is a request of SolrJ (`SolrPing`, `SolrQuery`, `QueryRequest`, `UpdateRequest`, or another `SolrRequest`, which is sent as it is) runs its own operation, as before: the route builds it. - Otherwise the `CamelSolrOperation` header, or else the `operation` option, decides. - The body decides only when neither is set, as before: the `CamelSolrQueryString` header searches, a Map or a file inserts, and a Collection inserts, or deletes by id when it holds Strings. - A `CamelSolrOperation` header with a value that is not an operation fails with an `IllegalArgumentException` that lists the operations; the deprecated names still work. - The solr page says how the operation is chosen, and the upgrade guide has entries for 4.24, and for 4.22.3 and 4.18.6, as the fix is to be backported (`port/camel-4.22.x`, `port/camel-4.18.x`; the same code is on both branches). **Tests** (`SolrInsertAndDeleteTest`, against the Solr container of camel-test-infra-solr) - `testInsertHeaderDoesNotDeleteTheIdsOfTheBody` and `testInsertOptionDoesNotDeleteTheIdsOfTheBody`: a List of ids sent with INSERT, as the header or the option, keeps the documents. - `testUnknownOperationFails`: a `CamelSolrOperation` of `NOSUCH` fails. - The three fail without the fix. The 44 tests of camel-solr pass (one skipped, as before). _Claude Code on behalf of davsclaus_ 🤖 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]
