allthingssecurity commented on PR #28533: URL: https://github.com/apache/camel/pull/28533#issuecomment-6436333042
@davsclaus thanks, you're right. Added the test in 7980447949d4 (a new commit on top, test only). It settles the follow-up from the description, so no JIRA is needed for it. New `CosmosDbEndpointClientRestartTest.aProducerUsesTheNewClientAfterTheCamelContextIsStartedAgain`. `CosmosDbClientFactory` is mocked (`mockStatic`) to return two clients. The test adds a route with an endpoint that creates its own client, checks that the endpoint holds the first one, runs `context.stop()`, checks that the first client was closed, and runs `context.start()`. The endpoint then holds the second client, and an exchange through the producer (`operation=createDatabase`) calls `createDatabaseIfNotExists` on the second client and never on the first. Two notes: - It is in its own class rather than in `CosmosDbEndpointClientLifecycleTest`. A `CamelContext` stop also clears the beans bound with `@BindToRegistry` (a lookup of `cosmosClient` returns null after `context.stop()`), so the autowired routes of that class fail to start again with "database endpoint must be specified". That is a test-harness effect, not the component. - On a CamelContext restart the routes are created again from their definitions, so the producer and consumer are new instances that wrap the new client. To check, I made the producer wrap the client only once (`if (clientWrapper == null)` in `doInit`), and the test still passed. A route stop/start does not stop the endpoint, so its client stays open there. Either way, no consumer or producer is left with the closed client. camel-azure-cosmosdb unit tests: 25 run, 0 failures. The formatter and import sort made no changes. I removed the follow-up paragraph from the description and corrected the test count (it said 23; the module had 24 tests before this commit). _Claude Code on behalf of allthingssecurity_ -- 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]
