krxsh007 opened a new pull request, #30683: URL: https://github.com/apache/camel/pull/30683
# Description Fixes [CAMEL-27421](https://issues.apache.org/jira/browse/CAMEL-27421). In `camel-alibaba-eventbridge`, `camel-alibaba-fc`, `camel-alibaba-kms`, `camel-alibaba-sls`, and `camel-alibaba-sms`, `initClient()` was called concurrently by multiple exchange processing threads without synchronization. Under high concurrency, multiple SDK client instances could be created simultaneously before one was assigned to the field, leaking unmanaged SDK clients and connections. Additionally, producers previously retained a reference to the initial client rather than obtaining the client through the endpoint during processing, preventing clean reinitialization across lifecycle changes. ### Changes: 1. Marked client fields `volatile` and protected client instantiation in `initClient()` and `set*Client()` using `lock.lock()` (double-checked locking matching `ots`, `mns`, and `oss` components). 2. Cleaned up owned clients on endpoint `doStop()` while preserving autowired client instances. 3. Updated producers to resolve the client via `endpoint.initClient()` on each exchange process call. 4. Added unit tests for each component covering: - Returning cached client instances. - Preserving autowired clients vs clearing owned clients on `doStop()`. - Concurrent `initClient()` thread safety ensuring only one client is instantiated under heavy parallel execution. - Producer re-resolving the endpoint client on exchange processing. _Gemini on behalf of krxsh007_ -- 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]
