[ 
https://issues.apache.org/jira/browse/CAMEL-27003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-27003.
---------------------------------
    Resolution: Fixed

Fixed via https://github.com/apache/camel/pull/30120

> camel-alibaba-mns, camel-alibaba-oss: initClient can create two clients, and 
> only one of them is closed
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27003
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27003
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 4.23.0
>            Reporter: Saravanakumar Selvaraj
>            Assignee: Saravanakumar Selvaraj
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Follow-up to CAMEL-26971 (camel-alibaba-ots), as suggested in the review of 
> https://github.com/apache/camel/pull/30066.
> MNSEndpoint.initClient and OSSEndpoint.initClient create the client of the 
> endpoint with the same check-then-create that AlibabaOtsEndpoint.initClient 
> had. The methods are not synchronized, and the fields mnsClient and ossClient 
> are not volatile. Both were found by reading the code, not by a failing run.
> 1. camel-alibaba-mns
> MNSProducer.process calls MNSEndpoint.initClient for each exchange, and 
> MNSConsumer.poll calls it for each poll. Two messages that are processed at 
> the same time, before a client exists, can each create an MNSClient. The 
> endpoint keeps only the last one, and doStop closes only that one. The other 
> client is never closed.
> 2. camel-alibaba-oss
> OSSProducer.process calls OSSEndpoint.initClient while the producer has no 
> client, and OSSConsumer.doStart calls it when the consumer starts. Two 
> messages that are processed at the same time, before a client exists, can 
> each create an OSSClient. The endpoint keeps only the last one, and doStop 
> closes only that one. The other client is never closed.
> The other Alibaba endpoints (eventbridge, fc, kms, sls, sms) create their 
> client in the same way, but their doStop only drops the reference, so they 
> are not part of this ticket.
> Not checked: whether a failed client creation leaves resources of these two 
> SDKs behind, as it did in camel-alibaba-ots.
> Possible fix: as in CAMEL-26971. Make the field volatile, and create the 
> client under the lock of the endpoint with a second check inside the lock.
> Claude Code on behalf of saravanakumar1987



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

Reply via email to