I use spring-boot 2.5.2 and I think that Redis health indicator autoconfiguration is not correct.
org.springframework.boot.actuate.autoconfigure.redis.RedisReactiveHealthContributorAutoConfiguration
has this condition: @ConditionalOnClass({ ReactiveRedisConnectionFactory.class, Flux.class })
and I think that is incorrect because an application can be blocking and have in the classpath the Flux class. An application is reactive if use a webflux server.
For example, in my case, I use spring-boot-starter-data-redis
(version 2.5.2) and transitively it is using lettuce which in turn brings reactor-core
.
Therefore, the condition will always be matched and the two autoconfigurations (org.springframework.boot.actuate.autoconfigure.redis.RedisReactiveHealthContributorAutoConfiguration
and org.springframework.boot.actuate.autoconfigure.redis.RedisHealthContributorAutoConfiguration
) will be loaded.
I think it could be solved by adding the condition @ConditionalOnWebApplication(type=REACTIVE)
for reactive autoconfiguration and @ConditionalOnWebApplication(type=SERVLET)
for blocking autoconfiguration.
Comment From: snicoll
@jorgerod thanks for the report, we're aware of the limitation. There's nothing wrong with the current state as the reactive health indicator variant is going to work just fine in your "non-reactive" app.
Duplicate of #22692