[
https://issues.apache.org/jira/browse/CAMEL-26971?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Saravanakumar Selvaraj reassigned CAMEL-26971:
----------------------------------------------
Assignee: Saravanakumar Selvaraj
> camel-alibaba-ots: initClient can create two clients, and a failed client
> creation leaks SDK threads
> ----------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26971
> URL: https://issues.apache.org/jira/browse/CAMEL-26971
> Project: Camel
> Issue Type: Bug
> Affects Versions: 4.23.0
> Reporter: Saravanakumar Selvaraj
> Assignee: Saravanakumar Selvaraj
> Priority: Minor
>
> Two defects in how AlibabaOtsEndpoint creates its SyncClient. They were
> listed in the description of https://github.com/apache/camel/pull/29991
> (CAMEL-23832). Both were found by reading the code, not by a failing run.
> 1. Two clients for one endpoint
> AlibabaOtsEndpoint.initClient (line 131) is not synchronized, and the
> otsClient field is not volatile. AlibabaOtsProducer.process calls initClient
> for each exchange. Two messages that are processed at the same time, before a
> client exists, can each create a SyncClient. The endpoint keeps only the last
> one, and doStop shuts down only that one. The other client is never shut down.
> 2. A failed client creation leaks SDK threads
> When AlibabaOtsUtils.createClient throws, the field stays null, so the
> creation is tried again for each message. The Tablestore SDK (5.17.14)
> rejects an endpoint that does not start with http:// or https://, and an
> instance name that it does not accept, in the constructor of InternalClient.
> Before these checks run, the constructor has already created a
> ResourceManager, which starts the HTTP client and the connection evictor of
> the SDK (ClientResources, AsyncServiceClient). Nothing shuts them down when a
> check fails. With such an endpoint or instance name, each message therefore
> leaves these threads behind.
> Possible fix: make the client creation in initClient thread-safe, and check
> the endpoint and the instance name before the SyncClient constructor is
> called.
> Claude Code on behalf of saravanakumar1987
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)