allthingssecurity opened a new pull request, #30980: URL: https://github.com/apache/camel/pull/30980
# Description [CAMEL-27617](https://issues.apache.org/jira/browse/CAMEL-27617) Fixes the six points of the ticket, which were found while the option descriptions of camel-elasticsearch were improved for CAMEL-23832 (#30954). I checked each point against main first; all six are real. 1. **useScroll with disconnect=true** (fixed). The producer closed the client right after the first search, so the next scroll request failed while the route read the body (`Request execution cancelled`). The producer now hands the client it created, with its sniffer and transport, to the `ElasticsearchScrollRequestIterator`, which closes them when it is closed. The next exchange creates a new client. With disconnect=true the client now stays open until the iterator is closed, which the streaming split and the try-with-resources example on the doc page already do. 2. **Cleanup skipped on failure** (fixed). The cleanup now runs in `whenComplete`, so also when the request fails, and in the catch block of `process()`, for an exception thrown before the request is sent (such as an Index without a body). The headers set from the options are removed and, with disconnect=true, the client is closed. The context records each header as it is set, so the cleanup only removes the headers set so far. The exception on the exchange is the same as before. 3. **CamelElasticsearchEnableDocumentOnlyMode header never removed** (fixed). It is tracked like the other headers set from the options and removed by the cleanup. A header that the message already had is kept. 4. **sniffAfterFailureDelay has no effect** (fixed). With enableSniffer, the client gets a `SniffOnFailureListener` (`RestClientBuilder.setFailureListener`), which is given the Sniffer once it is built. A failed node now starts a sniff, and the next sniff runs sniffAfterFailureDelay later, as the option says. 5. **No hostAddresses and no client** (fixed). The producer now fails to start with `The hostAddresses option, or the client option of the elasticsearch component, is required` instead of logging a warning and failing each exchange with a NullPointerException. Such a route could not send anything before, so I did not add an upgrade guide entry. 6. **certificatePath component option without supportFileReference** (fixed). Added `supportFileReference = true`, like the endpoint option. The component JSON and the catalog copy are regenerated. The component DSL does not print this flag for component options, so it does not change. Tests, all unit tests against a local fake node (JDK `HttpServer`) like the other unit tests of the module, no Docker: - `ElasticsearchProducerCleanupTest`: the headers are removed after a successful request (point 3), after a request the node rejects and after a body the producer rejects (point 2, also checks that the client is closed with disconnect=true), and a scroll with disconnect=true reads both pages, sends the clear-scroll request and closes the client when the iterator is closed (point 1). - `ElasticsearchProducerSnifferTest`: a request that fails with 503 makes the sniffer sniff again, and once more sniffAfterFailureDelay later (point 4). - `ElasticsearchProducerClientLifecycleTest.producerWithoutHostAddressesAndClientFailsToStart` (point 5). Of the 7 new tests, 6 fail on main and pass with the fix; `aDocumentOnlyModeHeaderOfTheMessageIsKept` is a control that passes on both. The new tests pass 5 runs in a row. The camel-elasticsearch unit tests pass: 65 run, 0 failures, 0 errors (the IT tests were not run). This branch touches some of the files of #30954, so one of the two will need a rebase. # 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): [CAMEL-27617](https://issues.apache.org/jira/browse/CAMEL-27617). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-elasticsearch with the camel-package-maven-plugin, which regenerated the component JSON, and committed it with its catalog copy. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 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]
