Saravanakumar Selvaraj created CAMEL-27421:
----------------------------------------------

             Summary: camel-alibaba: initClient of eventbridge, fc, kms, sls 
and sms can create more than one client
                 Key: CAMEL-27421
                 URL: https://issues.apache.org/jira/browse/CAMEL-27421
             Project: Camel
          Issue Type: Improvement
            Reporter: Saravanakumar Selvaraj


CAMEL-26971 and CAMEL-27003 made camel-alibaba-ots, camel-alibaba-mns and 
camel-alibaba-oss create their client once. Five Alibaba components still 
create it without a lock: eventbridge, fc, kms, sls and sms.

In each of the five endpoints, initClient() returns the client field when it is 
set. Otherwise it creates a client and stores it in the field. The method takes 
no lock, and the field is not volatile. The producers of eventbridge, fc, kms 
and sms keep the client in their own field the same way. The producer of sls 
calls initClient() for each exchange.

A producer can process exchanges on several threads. When the first exchanges 
arrive at the same time, each thread can find no client and create one. The 
endpoint keeps the client that was stored last, and a producer can keep another 
one.

The effect is small. The five clients have no close method, and a client that 
Camel drops holds no thread and no connection. So this is not the leak of 
CAMEL-26971 and CAMEL-27003. Still, the first exchanges can use different 
clients, and a thread can read the field while another thread writes it.

Proposed change: create the client under the endpoint lock, with a volatile 
field, as ots, mns and oss do. The producers then use the client that 
initClient() returns.

_Claude Code on behalf of saravanakumar1987_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to