This is an automated email from the ASF dual-hosted git repository.

christophd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c578a42a776d909231247e9d3fc99acf7d4085ba
Author: Christoph Deppisch <[email protected]>
AuthorDate: Thu Oct 8 21:48:31 2026 +0200

    CAMEL-25333: Address review feedback on camel-openfeature component
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../openfeature/OpenFeatureComponent.java          | 30 ++++++++++++++--------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git 
a/components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java
 
b/components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java
index b68219216bcb..ea636a3cef0f 100644
--- 
a/components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java
+++ 
b/components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java
@@ -122,31 +122,41 @@ public class OpenFeatureComponent extends 
DefaultComponent {
 
     @Override
     protected void doStop() throws Exception {
+        if (api == null) {
+            return;
+        }
+
         OpenFeatureAPI localApi = api;
         api = null;
-        for (DomainBinding binding : domainBindings.values()) {
-            binding.shutdown();
+
+        for (Map.Entry<String, DomainBinding> bindingEntry : 
domainBindings.entrySet()) {
+            Object lock = domainLocks.computeIfAbsent(bindingEntry.getKey(), k 
-> new Object());
+            synchronized (lock) {
+                bindingEntry.getValue().shutdown();
+            }
         }
         domainBindings.clear();
         domainLocks.clear();
-        if (localApi != null) {
-            try {
-                localApi.shutdown();
-            } catch (Exception e) {
-                LOG.debug("Error shutting down OpenFeature API: {}", 
e.getMessage(), e);
-            }
+        try {
+            localApi.shutdown();
+        } catch (Exception e) {
+            LOG.debug("Error shutting down OpenFeature API: {}", 
e.getMessage(), e);
         }
         super.doStop();
     }
 
     Client acquireOrRegister(String domain, ProviderSupplier providerSupplier) 
throws Exception {
-        OpenFeatureAPI localApi = api;
-        if (localApi == null) {
+        if (api == null) {
             throw new IllegalStateException("OpenFeature component is not 
started");
         }
 
         Object lock = domainLocks.computeIfAbsent(domain, k -> new Object());
         synchronized (lock) {
+            OpenFeatureAPI localApi = api;
+            if (localApi == null) {
+                throw new IllegalStateException("OpenFeature component is 
stopping or has been stopped");
+            }
+
             DomainBinding existing = domainBindings.get(domain);
             if (existing != null) {
                 existing.refCount++;

Reply via email to