gnodet-bot commented on code in PR #27440:
URL: https://github.com/apache/camel/pull/27440#discussion_r4210056378


##########
components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openfeature;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import dev.openfeature.sdk.Client;
+import dev.openfeature.sdk.FeatureProvider;
+import dev.openfeature.sdk.OpenFeatureAPI;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component("openfeature")
+public class OpenFeatureComponent extends DefaultComponent {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(OpenFeatureComponent.class);
+
+    @Metadata
+    private OpenFeatureConfiguration configuration = new 
OpenFeatureConfiguration();
+
+    private volatile OpenFeatureAPI api;
+    private final Map<String, DomainBinding> domainBindings = new 
ConcurrentHashMap<>();
+
+    private static class DomainBinding {
+        final FeatureProvider provider;
+        final boolean owned;
+        int refCount;
+        File tempFlagFile;
+
+        DomainBinding(FeatureProvider provider, boolean owned) {
+            this.provider = provider;
+            this.owned = owned;
+            this.refCount = 1;
+        }
+
+        void shutdown() {
+            if (owned) {
+                try {
+                    provider.shutdown();
+                } catch (Exception e) {
+                    LOG.debug("Error shutting down owned provider: {}", 
e.getMessage(), e);
+                }
+            }
+
+            if (tempFlagFile != null) {
+                try {
+                    Files.deleteIfExists(tempFlagFile.toPath());
+                } catch (IOException e) {
+                    LOG.debug("Error deleting temp flag file: {}", 
e.getMessage(), e);
+                }
+                tempFlagFile = null;
+            }
+        }
+    }
+
+    static class ProviderRegistration {
+        final FeatureProvider provider;
+        final boolean owned;
+        File tempFlagFile;
+
+        ProviderRegistration(FeatureProvider provider, boolean owned) {
+            this.provider = provider;
+            this.owned = owned;
+        }
+    }
+
+    @FunctionalInterface
+    interface ProviderSupplier {
+        ProviderRegistration get() throws Exception;
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+        String domain = remaining;
+        String evaluationType = null;
+        int idx = remaining.indexOf('/');
+        if (idx >= 0) {
+            domain = remaining.substring(0, idx);
+            String pathValue = remaining.substring(idx + 1);
+            if (!pathValue.isBlank()) {
+                evaluationType = pathValue;
+            }
+        }
+        OpenFeatureEndpoint endpoint = new OpenFeatureEndpoint(uri, this, 
domain, evaluationType, configuration.copy());
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        api = OpenFeatureAPI.createIsolated();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        OpenFeatureAPI localApi = api;
+        api = null;
+        for (DomainBinding binding : domainBindings.values()) {
+            binding.shutdown();
+        }
+        domainBindings.clear();
+        if (localApi != null) {
+            try {
+                localApi.shutdown();
+            } catch (Exception e) {
+                LOG.debug("Error shutting down OpenFeature API: {}", 
e.getMessage(), e);
+            }
+        }
+        super.doStop();
+    }
+
+    synchronized Client acquireOrRegister(String domain, ProviderSupplier 
providerSupplier) throws Exception {
+        DomainBinding existing = domainBindings.get(domain);
+        if (existing != null) {
+            existing.refCount++;
+            return api.getClient(domain);
+        }
+
+        ProviderRegistration reg = providerSupplier.get();
+        try {
+            api.setProviderAndWait(domain, reg.provider);

Review Comment:
   ⚠️ **Lock contention: slow I/O inside synchronized**
   
   `acquireOrRegister()` is `synchronized` on the component's intrinsic lock, 
and it holds that lock while executing two potentially slow operations:
   - `providerSupplier.get()` (line 142): resolves the provider, possibly 
involving Camel registry lookups, bean instantiation, or I/O
   - `api.setProviderAndWait()` (line 144): a **blocking** RPC call to register 
the provider and wait for readiness
   
   This means every concurrent endpoint start that touches a different domain 
is serialized behind the slowest provider initialization. In a context with 
several flagd-backed endpoints, the startup time compounds linearly.
   
   Consider double-checked locking with a 
`ConcurrentHashMap.computeIfAbsent`-style pattern, or a per-domain lock (e.g. 
`domainLocks.computeIfAbsent(domain, k -> new Object())`) so registrations of 
independent domains can proceed in parallel.



##########
components/camel-openfeature/src/main/java/org/apache/camel/component/openfeature/OpenFeatureComponent.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openfeature;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import dev.openfeature.sdk.Client;
+import dev.openfeature.sdk.FeatureProvider;
+import dev.openfeature.sdk.OpenFeatureAPI;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component("openfeature")
+public class OpenFeatureComponent extends DefaultComponent {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(OpenFeatureComponent.class);
+
+    @Metadata
+    private OpenFeatureConfiguration configuration = new 
OpenFeatureConfiguration();
+
+    private volatile OpenFeatureAPI api;
+    private final Map<String, DomainBinding> domainBindings = new 
ConcurrentHashMap<>();
+
+    private static class DomainBinding {
+        final FeatureProvider provider;
+        final boolean owned;
+        int refCount;
+        File tempFlagFile;
+
+        DomainBinding(FeatureProvider provider, boolean owned) {
+            this.provider = provider;
+            this.owned = owned;
+            this.refCount = 1;
+        }
+
+        void shutdown() {
+            if (owned) {
+                try {
+                    provider.shutdown();
+                } catch (Exception e) {
+                    LOG.debug("Error shutting down owned provider: {}", 
e.getMessage(), e);
+                }
+            }
+
+            if (tempFlagFile != null) {
+                try {
+                    Files.deleteIfExists(tempFlagFile.toPath());
+                } catch (IOException e) {
+                    LOG.debug("Error deleting temp flag file: {}", 
e.getMessage(), e);
+                }
+                tempFlagFile = null;
+            }
+        }
+    }
+
+    static class ProviderRegistration {
+        final FeatureProvider provider;
+        final boolean owned;
+        File tempFlagFile;
+
+        ProviderRegistration(FeatureProvider provider, boolean owned) {
+            this.provider = provider;
+            this.owned = owned;
+        }
+    }
+
+    @FunctionalInterface
+    interface ProviderSupplier {
+        ProviderRegistration get() throws Exception;
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+        String domain = remaining;
+        String evaluationType = null;
+        int idx = remaining.indexOf('/');
+        if (idx >= 0) {
+            domain = remaining.substring(0, idx);
+            String pathValue = remaining.substring(idx + 1);
+            if (!pathValue.isBlank()) {
+                evaluationType = pathValue;
+            }
+        }
+        OpenFeatureEndpoint endpoint = new OpenFeatureEndpoint(uri, this, 
domain, evaluationType, configuration.copy());
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        api = OpenFeatureAPI.createIsolated();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        OpenFeatureAPI localApi = api;
+        api = null;
+        for (DomainBinding binding : domainBindings.values()) {

Review Comment:
   ⚠️ **Race condition: double-shutdown between doStop() and 
unregisterEndpoint()**
   
   `doStop()` is NOT synchronized, but it iterates `domainBindings.values()` 
calling `binding.shutdown()` on each. Meanwhile, `unregisterEndpoint()` IS 
synchronized and can also call `binding.shutdown()` when `refCount` reaches 
zero.
   
   If a route is being stopped concurrently with the component stopping, the 
same `DomainBinding.shutdown()` can be called twice. `DomainBinding.shutdown()` 
has no idempotency guard — it calls `provider.shutdown()` and deletes the temp 
file unconditionally on every invocation, which can lead to redundant provider 
shutdown calls and a potential NPE on the second 
`Files.deleteIfExists(tempFlagFile.toPath())` call (after the first one sets 
`tempFlagFile = null`… actually line 2090 does null it, but that nulling is 
itself not thread-safe if `doStop` races with `unregisterEndpoint`).
   
   Two options:
   1. Make `doStop()` synchronized (simplest)
   2. Add an idempotency guard to `DomainBinding.shutdown()` using an 
`AtomicBoolean`



##########
components/camel-openfeature/src/test/java/org/apache/camel/component/openfeature/OpenFeatureProducerTest.java:
##########
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openfeature;
+
+import java.util.List;
+import java.util.Map;
+
+import dev.openfeature.sdk.MutableContext;
+import dev.openfeature.sdk.Value;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class OpenFeatureProducerTest extends CamelTestSupport {
+
+    private static final String FLAGS_RESOURCE = 
"classpath:openfeature/flags.json";
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:boolean-flag")
+                        
.to("openfeature:test?flagKey=enrichment-enabled&flagsResource=" + 
FLAGS_RESOURCE);
+
+                from("direct:disabled-flag")
+                        
.to("openfeature:test-disabled?flagKey=disabled-flag&flagsResource=" + 
FLAGS_RESOURCE);
+
+                from("direct:string-flag")
+                        
.to("openfeature:test-string?flagKey=new-routing-algorithm&defaultValue=unknown&flagsResource="
+                            + FLAGS_RESOURCE);
+
+                from("direct:result-property")
+                        
.to("openfeature:test-prop?flagKey=enrichment-enabled&resultProperty=flagResult&flagsResource="
+                            + FLAGS_RESOURCE);
+
+                from("direct:targeted-flag")
+                        
.to("openfeature:test-targeted?flagKey=hazmat-compliance-v2&defaultValue=v1&flagsResource="
+                            + FLAGS_RESOURCE
+                            + "&contextFromBody=true");
+
+                from("direct:variant-type")
+                        
.to("openfeature:test-variant/variant?flagKey=new-routing-algorithm&flagsResource="
+                            + FLAGS_RESOURCE);
+
+                from("direct:boolean-type-explicit")
+                        
.to("openfeature:test-bool-type/boolean?flagKey=enrichment-enabled&flagsResource="
+                            + FLAGS_RESOURCE);
+
+                from("direct:is-enabled")
+                        
.to("openfeature:test-is-enabled/isEnabled?flagKey=enrichment-enabled&flagsResource="
+                            + FLAGS_RESOURCE);
+
+                from("direct:targeted-boolean")
+                        
.to("openfeature:test-targeted-bool?flagKey=targeted-boolean&flagsResource="
+                            + FLAGS_RESOURCE
+                            + "&contextFromBody=true");
+
+                from("direct:targeted-boolean-header")
+                        
.to("openfeature:test-targeted-bool-hdr?flagKey=targeted-boolean&flagsResource="
+                            + FLAGS_RESOURCE);
+            }
+        };
+    }
+
+    @Test
+    void testBooleanFlagEvaluationTrue() {
+        Object result = template.requestBody("direct:boolean-flag", "ignored");
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testDisabledFlagReturnsDefault() {
+        Object result = template.requestBody("direct:disabled-flag", 
"ignored");
+        assertThat(result).isEqualTo(false);
+    }
+
+    @Test
+    void testStringFlagEvaluation() {
+        Object result = template.requestBody("direct:string-flag", "ignored");
+        assertThat(result).isEqualTo("content-based-router");
+    }
+
+    @Test
+    void testResultPropertyPreservesBody() {
+        Exchange exchange = template.request("direct:result-property", e -> 
e.getMessage().setBody("original"));
+        
assertThat(exchange.getMessage().getBody(String.class)).isEqualTo("original");
+        assertThat(exchange.getProperty("flagResult")).isEqualTo(true);
+    }
+
+    @Test
+    void testEvaluationContextTargetedEnterprise() {
+        Object result = template.requestBody("direct:targeted-flag",
+                Map.of("targetingKey", "order-123", "customer_tier", 
"ENTERPRISE"));
+        assertThat(result).isEqualTo("v2");
+    }
+
+    @Test
+    void testEvaluationContextTargetedVip() {
+        Object result = template.requestBody("direct:targeted-flag",
+                Map.of("targetingKey", "order-456", "customer_tier", "VIP"));
+        assertThat(result).isEqualTo("v2");
+    }
+
+    @Test
+    void testEvaluationContextTargetedStandard() {
+        Object result = template.requestBody("direct:targeted-flag",
+                Map.of("targetingKey", "order-789", "customer_tier", 
"STANDARD"));
+        assertThat(result).isEqualTo("v1");
+    }
+
+    @Test
+    void testFlagKeyHeaderOverride() {
+        Object result = template.requestBodyAndHeader(
+                "direct:boolean-flag", "ignored",
+                OpenFeatureConstants.FLAG_KEY, "disabled-flag");
+        assertThat(result).isEqualTo(false);
+    }
+
+    @Test
+    void testTargetingKeyHeader() {
+        Exchange exchange = template.request("direct:targeted-flag", e -> {
+            e.getMessage().setBody(Map.of("customer_tier", "ENTERPRISE"));
+            e.getMessage().setHeader(OpenFeatureConstants.TARGETING_KEY, 
"order-header-123");
+        });
+        assertThat(exchange.getMessage().getBody()).isEqualTo("v2");
+    }
+
+    @Test
+    void testTargetingKeyProperty() {
+        Exchange exchange = template.request("direct:targeted-flag", e -> {
+            e.getMessage().setBody(Map.of("customer_tier", "VIP"));
+            e.setProperty(OpenFeatureConstants.TARGETING_KEY, 
"order-prop-456");
+        });
+        assertThat(exchange.getMessage().getBody()).isEqualTo("v2");
+    }
+
+    @Test
+    void testContextHeader() {
+        Exchange exchange = template.request("direct:targeted-flag", e -> {
+            e.getMessage().setBody("ignored");
+            e.getMessage().setHeader(OpenFeatureConstants.EVALUATION_CONTEXT,
+                    Map.of("targetingKey", "order-ctx-789", "customer_tier", 
"ENTERPRISE"));
+        });
+        assertThat(exchange.getMessage().getBody()).isEqualTo("v2");
+    }
+
+    @Test
+    void testContextHeaderOverridesBody() {
+        Exchange exchange = template.request("direct:targeted-flag", e -> {
+            e.getMessage().setBody(Map.of("targetingKey", "order-body", 
"customer_tier", "STANDARD"));
+            e.getMessage().setHeader(OpenFeatureConstants.EVALUATION_CONTEXT,
+                    Map.of("customer_tier", "ENTERPRISE"));
+        });
+        assertThat(exchange.getMessage().getBody()).isEqualTo("v2");
+    }
+
+    @Test
+    void testVariantEvaluationTypeWithDefaultDefaultValue() {
+        Object result = template.requestBody("direct:variant-type", "ignored");
+        assertThat(result).isEqualTo("content-based-router");
+    }
+
+    @Test
+    void testExplicitBooleanEvaluationType() {
+        Object result = template.requestBody("direct:boolean-type-explicit", 
"ignored");
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testIsEnabledEvaluationType() {
+        Object result = template.requestBody("direct:is-enabled", "ignored");
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testIsEnabledDisabledFlag() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:is-enabled-disabled")
+                        
.to("openfeature:test-is-enabled-off/isEnabled?flagKey=disabled-flag&flagsResource="
+                            + FLAGS_RESOURCE);
+            }
+        });
+        Object result = template.requestBody("direct:is-enabled-disabled", 
"ignored");
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(false);
+    }
+
+    @Test
+    void testInlineFlags() throws Exception {
+        String inlineFlags = """
+                
{"flags":{"inline-flag":{"state":"ENABLED","variants":{"on":true,"off":false},"defaultVariant":"on"}}}""";
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inline-flag")
+                        
.to("openfeature:test-inline?flagKey=inline-flag&flags=" + inlineFlags);
+            }
+        });
+        Object result = template.requestBody("direct:inline-flag", "ignored");
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testBooleanFlagWithTargetingKeyReturnsBooleanNotString() {
+        Exchange exchange = template.request("direct:targeted-boolean", e -> {
+            e.getMessage().setBody(Map.of("customer_tier", "ENTERPRISE"));
+            e.getMessage().setHeader(OpenFeatureConstants.TARGETING_KEY, 
"user-123");
+        });
+        Object result = exchange.getMessage().getBody();
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testBooleanFlagWithTargetingKeyDefaultVariant() {
+        Exchange exchange = template.request("direct:targeted-boolean", e -> {
+            e.getMessage().setBody(Map.of("customer_tier", "STANDARD"));
+            e.getMessage().setHeader(OpenFeatureConstants.TARGETING_KEY, 
"user-456");
+        });
+        Object result = exchange.getMessage().getBody();
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(false);
+    }
+
+    @Test
+    void testBooleanFlagWithMapBodyReturnsBoolean() {
+        Object result = template.requestBody("direct:targeted-boolean",
+                Map.of("targetingKey", "user-789", "customer_tier", "VIP"));
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(true);
+    }
+
+    @Test
+    void testMapBodyNotUsedAsContextByDefault() {
+        Object result = template.requestBody("direct:targeted-boolean-header",
+                Map.of("targetingKey", "user-789", "customer_tier", 
"ENTERPRISE"));
+        assertThat(result).isInstanceOf(Boolean.class);
+        assertThat(result).isEqualTo(false);
+    }
+
+    @Test
+    void testEvaluationDetailsHeaders() {
+        Exchange exchange = template.request("direct:boolean-flag", e -> 
e.getMessage().setBody("ignored"));
+        
assertThat(exchange.getMessage().getHeader(OpenFeatureConstants.EVALUATION_VARIANT,
 String.class))
+                .isNotNull();
+        
assertThat(exchange.getMessage().getHeader(OpenFeatureConstants.EVALUATION_REASON,
 String.class))
+                .isNotNull();
+        
assertThat(exchange.getMessage().getHeader(OpenFeatureConstants.EVALUATION_ERROR_CODE))
+                .isNull();
+    }
+
+    @Test
+    void testStaleErrorHeaderClearedOnSuccess() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:stale-header-test")
+                        
.to("openfeature:test-stale?flagKey=enrichment-enabled&flagsResource=" + 
FLAGS_RESOURCE);
+            }
+        });
+
+        Exchange exchange = template.request("direct:stale-header-test", e -> {
+            e.getMessage().setBody("ignored");
+            
e.getMessage().setHeader(OpenFeatureConstants.EVALUATION_ERROR_CODE, 
"FLAG_NOT_FOUND");
+        });
+        assertThat(exchange.getMessage().getBody()).isEqualTo(true);
+        
assertThat(exchange.getMessage().getHeader(OpenFeatureConstants.EVALUATION_ERROR_CODE)).isNull();
+    }
+
+    @Test
+    void testToValuePreservesLargeLong() {
+        long largeLong = Long.MAX_VALUE;
+        MutableContext ctx = OpenFeatureEndpoint.buildMutableContext(
+                "user-1", Map.of("signupTs", largeLong));
+        Value value = ctx.getValue("signupTs");
+        assertThat(value).isNotNull();
+        assertThat(value.asLong()).isEqualTo(largeLong);
+    }
+
+    @Test
+    void testToValueHandlesFloat() {
+        MutableContext ctx = OpenFeatureEndpoint.buildMutableContext(
+                "user-1", Map.of("score", 3.14f));
+        Value value = ctx.getValue("score");
+        assertThat(value).isNotNull();
+        assertThat(value.asDouble()).isCloseTo(3.14, 
org.assertj.core.data.Offset.offset(0.01));
+    }
+
+    @Test
+    void testToValueHandlesNestedMap() {
+        Map<String, Object> nested = Map.of("city", "Berlin", "zip", 10115);
+        MutableContext ctx = OpenFeatureEndpoint.buildMutableContext(
+                "user-1", Map.of("address", nested));
+        Value value = ctx.getValue("address");
+        assertThat(value).isNotNull();
+        assertThat(value.isStructure()).isTrue();
+        
assertThat(value.asStructure().getValue("city").asString()).isEqualTo("Berlin");
+        
assertThat(value.asStructure().getValue("zip").asInteger()).isEqualTo(10115);
+    }
+
+    @Test
+    void testToValueHandlesList() {
+        MutableContext ctx = OpenFeatureEndpoint.buildMutableContext(
+                "user-1", Map.of("tags", List.of("premium", "beta")));
+        Value value = ctx.getValue("tags");
+        assertThat(value).isNotNull();
+        assertThat(value.isList()).isTrue();
+        assertThat(value.asList()).hasSize(2);
+        assertThat(value.asList().get(0).asString()).isEqualTo("premium");
+    }
+
+    @Test
+    void testFailedEndpointStartDoesNotAffectSharedDomain() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:shared-domain")
+                        
.to("openfeature:shared?flagKey=enrichment-enabled&flagsResource=" + 
FLAGS_RESOURCE);
+            }
+        });
+
+        Object result = template.requestBody("direct:shared-domain", 
"ignored");
+        assertThat(result).isEqualTo(true);
+
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() {
+                    from("direct:bad-endpoint")
+                            
.to("openfeature:shared?flagKey=enrichment-enabled&provider=#nonexistent");

Review Comment:
   🐛 **Test doesn't exercise the scenario its name describes**
   
   `testFailedEndpointStartDoesNotAffectSharedDomain` claims to test that a 
failed endpoint start doesn't corrupt an existing shared domain binding. But it 
doesn't.
   
   The second `addRoutes` call uses domain `"shared"` with 
`provider=#nonexistent`. Inside `acquireOrRegister()`, the first check is:
   ```java
   DomainBinding existing = domainBindings.get(domain);
   if (existing != null) {
       existing.refCount++;
       return api.getClient(domain);
   }
   ```
   Since the first route already registered domain `"shared"`, `existing != 
null` is true, `providerSupplier.get()` is **never called**, and the 
`#nonexistent` bean is never resolved. The failure (if it even occurs) happens 
at Camel endpoint creation time before reaching `acquireOrRegister`, not in the 
failure path you intend to guard.
   
   The test should use a **different domain** for the bad endpoint (e.g. 
`openfeature:shared-bad?...`) to actually force the provider lookup and 
exercise the failure-isolation logic. Alternatively, use a distinct domain with 
a `ProviderSupplier` that throws directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to