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

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit 115f626f4e74b97d11d35e1c73ac5b7920bd1358
Author: Croway <[email protected]>
AuthorDate: Mon Sep 28 14:11:29 2026 +0200

    CAMEL-22760: Preserve Kafka bridge customizer precedence
---
 .../SpringKafkaPropertiesAutoConfiguration.java    | 12 ++++-
 .../SpringKafkaPropertiesBridgeTest.java           | 52 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git 
a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesAutoConfiguration.java
 
b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesAutoConfiguration.java
index 5f8a80e5b0a..21672d93890 100644
--- 
a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesAutoConfiguration.java
+++ 
b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesAutoConfiguration.java
@@ -23,6 +23,7 @@ import org.apache.camel.Component;
 import org.apache.camel.component.kafka.KafkaComponent;
 import org.apache.camel.component.kafka.KafkaConfiguration;
 import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -65,11 +66,13 @@ public class SpringKafkaPropertiesAutoConfiguration {
 
     private final KafkaProperties kafkaProperties;
     private final Binder binder;
+    private final Environment environment;
 
     public SpringKafkaPropertiesAutoConfiguration(
             KafkaProperties kafkaProperties,
             Environment environment) {
         this.kafkaProperties = kafkaProperties;
+        this.environment = environment;
         this.binder = Binder.get(environment);
     }
 
@@ -84,9 +87,16 @@ public class SpringKafkaPropertiesAutoConfiguration {
                 }
             }
 
+            @Override
+            public boolean isEnabled(String name, Component target) {
+                return target instanceof KafkaComponent
+                        && 
HierarchicalPropertiesEvaluator.evaluate(environment,
+                                "camel.component.customizer", 
"camel.component.kafka.customizer");
+            }
+
             @Override
             public int getOrder() {
-                return Ordered.LOWEST;
+                return Ordered.HIGHEST;
             }
         };
     }
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesBridgeTest.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesBridgeTest.java
index 1a190e3b300..2560e578e37 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesBridgeTest.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/springboot/SpringKafkaPropertiesBridgeTest.java
@@ -17,7 +17,9 @@
 package org.apache.camel.component.kafka.springboot;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
 import org.apache.camel.component.kafka.KafkaComponent;
+import org.apache.camel.spi.ComponentCustomizer;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -64,6 +66,56 @@ class SpringKafkaPropertiesBridgeTest {
                 });
     }
 
+    @Test
+    void shouldPreserveApplicationCustomizerValue() {
+        contextRunner
+                .withBean(ComponentCustomizer.class, () -> new 
ComponentCustomizer() {
+                    @Override
+                    public void configure(String name, Component target) {
+                        if (target instanceof KafkaComponent kafka) {
+                            
kafka.getConfiguration().setBrokers("custom-broker:9092");
+                        }
+                    }
+                })
+                .withPropertyValues(
+                        "spring.kafka.bootstrap-servers=broker1:9092",
+                        "camel.component.kafka.enabled=true")
+                .run(context -> {
+                    KafkaComponent kafka = context.getBean(CamelContext.class)
+                            .getComponent("kafka", KafkaComponent.class);
+                    assertThat(kafka.getConfiguration().getBrokers())
+                            .isEqualTo("custom-broker:9092");
+                });
+    }
+
+    @Test
+    void shouldRespectKafkaCustomizerDisableSwitch() {
+        contextRunner
+                .withPropertyValues(
+                        "spring.kafka.bootstrap-servers=broker1:9092",
+                        "camel.component.kafka.customizer.enabled=false",
+                        "camel.component.kafka.enabled=true")
+                .run(context -> {
+                    KafkaComponent kafka = context.getBean(CamelContext.class)
+                            .getComponent("kafka", KafkaComponent.class);
+                    assertThat(kafka.getConfiguration().getBrokers()).isNull();
+                });
+    }
+
+    @Test
+    void shouldRespectGlobalCustomizerDisableSwitch() {
+        contextRunner
+                .withPropertyValues(
+                        "spring.kafka.bootstrap-servers=broker1:9092",
+                        "camel.component.customizer.enabled=false",
+                        "camel.component.kafka.enabled=true")
+                .run(context -> {
+                    KafkaComponent kafka = context.getBean(CamelContext.class)
+                            .getComponent("kafka", KafkaComponent.class);
+                    assertThat(kafka.getConfiguration().getBrokers()).isNull();
+                });
+    }
+
     @Test
     void shouldBridgeSecurityProtocol() {
         contextRunner

Reply via email to