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

Work on CAMEL-26762 started by Andrea Cosentino.
------------------------------------------------
> camel-test-infra-common - SingletonService shuts a singleton service down 
> once per test class, at the same time
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26762
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26762
>             Project: Camel
>          Issue Type: Test
>          Components: camel-test-infra
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>
> {{SingletonService.addToStore}} registers a JVM shutdown hook on every 
> {{beforeAll}}, outside the {{computeIfAbsent}} that creates the singleton 
> once. A singleton service used by three test classes is therefore shut down 
> three times, by three hooks that run at the same time:
> {noformat}
> initialize() on main
> shutdown() entered on Thread-3, concurrent calls now 1
> shutdown() entered on Thread-2, concurrent calls now 2
> shutdown() entered on Thread-4, concurrent calls now 3
> {noformat}
> Found by Croway in the review of 
> [#29245|https://github.com/apache/camel/pull/29245] (CAMEL-26618), whose 
> Event Hubs service guards its {{shutdown()}} with a flag and {{synchronized}} 
> for this reason. The other singleton services (Blob, Queue, Data Lake, Key 
> Vault, Event Grid, Cosmos DB, and most test-infra services of other modules) 
> have no such guard.
> *Fix:* register the shutdown hook once, when the singleton is created (for 
> example in {{doInitializeService}}), and drop the guard of the Event Hubs 
> service.
> _Claude Code on behalf of Andrea Cosentino_



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

Reply via email to