allthingssecurity opened a new pull request, #30571: URL: https://github.com/apache/camel/pull/30571
# Description [CAMEL-27324](https://issues.apache.org/jira/browse/CAMEL-27324) `HazelcastIdempotentRepository` created without a `HazelcastInstance` (the no-argument constructor, for example as a bean in XML or YAML) creates a local Hazelcast member when it starts and shuts it down when it stops, but kept the field. The idempotent consumer stops its repository when its route is removed (a reload in dev mode, routes removed and added at runtime) and when CamelContext stops. The next start found the field set, did not create a new instance, and called `getMap` on the instance that was shut down: `HazelcastInstanceNotActiveException: Hazelcast instance is not active!`, so the route added again, or the CamelContext started again, failed to start. Fix: `doStop` clears the local instance and the `useLocalHzInstance` flag after shutting the instance down, so the next start creates a new local instance. `HazelcastAggregationRepository` and `HazelcastKeyValueRepository` already do this. A repository given a `HazelcastInstance` is unchanged (it never shuts that instance down). As before, the ids kept by a local instance are gone after it was shut down (the local instance is the only member unless other members join it). Tests: `HazelcastIdempotentRepositoryRestartTest`: the repository started, stopped and started again must add a new id; and a route with `idempotentConsumer` and the repository is removed and added again (as a reload does), and must route a new message. Runs (offline, Hazelcast 5.4.0, the test configuration `hazelcast-default.xml` of the module): both tests fail on main (`HazelcastInstanceNotActiveException`, and `FailedToStartRouteException` caused by it) and pass with the fix; camel-hazelcast tests under `org.apache.camel.component.hazelcast`, `org.apache.camel.processor.idempotent.hazelcast` and `org.apache.camel.processor.aggregate.hazelcast`: 298 run, 0 failures except `HazelcastAggregationRepositoryRoutesTest.checkAggregationFromTwoRoutes` and `HazelcastUserConfigSerializationFilterWarningTest.warnsForUserClientConfigWithoutFilter`, which fail on my machine also when run alone without the new test (`Unable to connect to any cluster` for the client config, two aggregated exch anges instead of one); neither uses `HazelcastIdempotentRepository`, CI will tell whether they fail elsewhere; the new test class 20 times in one JVM: 40 of 40. # 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-27324](https://issues.apache.org/jira/browse/CAMEL-27324). # 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 the core modules and camel-hazelcast with the formatter and import-sort plugins. No option or generated file changed. 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]
