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 8e7dadc50bea963ad14d9e0cde9fe4a1b8537c2a Author: Christoph Deppisch <[email protected]> AuthorDate: Thu Oct 8 13:21:54 2026 +0200 CAMEL-25333: Address review feedback on camel-openfeature component Fix two concurrency issues in OpenFeatureComponent: - Capture volatile api reference locally in acquireOrRegister() to prevent NPE when doStop() nulls api concurrently - Stop removing domain locks from ConcurrentHashMap to prevent split-monitor race between unregisterEndpoint and acquireOrRegister Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../camel/component/openfeature/OpenFeatureComponent.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 d218c482aeef..e790a297508f 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 @@ -139,17 +139,22 @@ public class OpenFeatureComponent extends DefaultComponent { } Client acquireOrRegister(String domain, ProviderSupplier providerSupplier) throws Exception { + OpenFeatureAPI localApi = api; + if (localApi == null) { + throw new IllegalStateException("OpenFeature component is not started"); + } + Object lock = domainLocks.computeIfAbsent(domain, k -> new Object()); synchronized (lock) { DomainBinding existing = domainBindings.get(domain); if (existing != null) { existing.refCount++; - return api.getClient(domain); + return localApi.getClient(domain); } ProviderRegistration reg = providerSupplier.get(); try { - api.setProviderAndWait(domain, reg.provider); + localApi.setProviderAndWait(domain, reg.provider); } catch (Exception e) { if (reg.owned) { try { @@ -170,7 +175,7 @@ public class OpenFeatureComponent extends DefaultComponent { DomainBinding binding = new DomainBinding(reg.provider, reg.owned); binding.tempFlagFile = reg.tempFlagFile; domainBindings.put(domain, binding); - return api.getClient(domain); + return localApi.getClient(domain); } } @@ -183,7 +188,6 @@ public class OpenFeatureComponent extends DefaultComponent { if (binding.refCount <= 0) { domainBindings.remove(domain); binding.shutdown(); - domainLocks.remove(domain); } } }
