I noticed that the configuration in KafkaStreamsAnnotationDrivenConfiguration looks a little unusual. It uses the nested KafkaStreamsFactoryBeanConfigurer class to configure the org.springframework.kafka.config.StreamsBuilderFactoryBean factory bean. However, it seems that org.springframework.kafka.config.StreamsBuilderFactoryBeanConfigurer would be more appropriate for configuring it.

KafkaStreamsFactoryBeanConfigurer requires a bean of type org.springframework.kafka.config.StreamsBuilderFactoryBean to be autowired. To be honest, injecting a factory bean into another bean and configuring it in afterPropertiesSet feels a bit odd to me. This comment in the code also raises concerns:

// Separate class required to avoid BeanCurrentlyInCreationException
static class KafkaStreamsFactoryBeanConfigurer implements InitializingBean {}

In contrast, org.springframework.kafka.config.StreamsBuilderFactoryBeanConfigurer is applied before org.springframework.kafka.config.StreamsBuilderFactoryBean is created, which aligns more closely with how configuration is typically applied.

I suggest considering the use of org.springframework.kafka.config.StreamsBuilderFactoryBeanConfigurer instead of KafkaStreamsFactoryBeanConfigurer in KafkaStreamsAnnotationDrivenConfiguration.

Also, perhaps StreamsBuilderFactoryBeanCustomizer could be deprecated or removed in favor of org.springframework.kafka.config.StreamsBuilderFactoryBeanConfigurer, as they serve similar purposes. The latter is already used directly in org.springframework.kafka.annotation.KafkaStreamsDefaultConfiguration.

https://github.com/spring-projects/spring-boot/compare/main...nosan:spring-boot:46668

Comment From: wilkinsona

Thanks, @nosan. This rang a bell and think that's because of #33819. This feels like it overlaps quite a bit with that issue, although it may not be an exact duplicate. WDYT?

Comment From: nosan

Thanks, @wilkinsona. I had overlooked #33819. I think this one can be considered a duplicate of it.