spring-projects / spring-kafka

Provides Familiar Spring Abstractions for Apache Kafka
https://projects.spring.io/spring-kafka
Apache License 2.0
2.17k stars 1.55k forks source link

Wrong comparison of server bootstrap addresses in KafkaTemplate.afterSingletonsInstantiated #3466

Closed bleipold1 closed 1 month ago

bleipold1 commented 1 month ago

In what version(s) of Spring for Apache Kafka are you seeing this issue?

3.2.3

Describe the bug

In line 490 of KafkaTemplate are the bootstrap server addresses of the producer factory and the bootstrap server addresses of the kafka admin bean compared with each other. In most cases this will fail, because producerServers is a list of strings and adminServers always string. Even if the string represents the same list.

To Reproduce

Expected behavior

If producerServers and adminServers represent the same bootstrap servers, the if branch should not be entered.

sobychacko commented 1 month ago

@bleipold1 Thanks for the report. We will look into this soon.

sobychacko commented 1 month ago

@bleipold1 While it looks like an issue, we are curious how you encountered this issue. If they don't match (even by type), then we get into the conditional for creating a new KafkaAdmin.

Also, this only happens if you have a Boot application because you always get the bootstrap server config from Boot as a List.

In summary, this doesn't look like a bug, but an optimization on KafkaTempate, i.e. if they are equal, then we don't need to create a new KafkaAdmin.