spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
73.81k stars 40.37k forks source link

Allow Kafka Admin Client's security protocol to be configured when using custom KafkaConnectionDetails #38342

Open Exidex opened 8 months ago

Exidex commented 8 months ago

Spring Boot hardcodes Kafka Admin Client security protocol to PLAINTEXT if custom KafkaConnectionDetails is used. For producer and consumer it is easy to work around using DefaultKafkaConsumerFactoryCustomizer and DefaultKafkaProducerFactoryCustomizer but AdminClient doesn't have similar customizer. Which means we cannot configure it security protocol in code.

Relevant piece of code:

https://github.com/spring-projects/spring-boot/blob/4a6762a356aa1d31c869e07c12db4ae48c39cf3d/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java#L208-L209

The only workaround I see is replacing AdminClient bean with custom one (which is not really desirable) or am I missing something?

Spring Boot version: 3.1.4

LukasHeimann commented 6 months ago

I'm also interested in having a KafkaAdminCustomizer to modify the default bean, similar to how there already is a customizer for the DefaultKafkaProducerFactory and the DefaultKafkaConsumerFactory (see https://github.com/spring-projects/spring-boot/issues/12003 and https://github.com/spring-projects/spring-boot/commit/d16074d8fdc457107177bca026635e4575fe0c08)