I was debugging an issue related to disabling HealthIndicators last week and noticed that Boot fetches the health indicators differently in the reactive case

The non-reactive configuration fetched the beans through the application context https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.java#L81

The reactive implementation has them injected https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointConfiguration.java#L48

The reason this caught my eye is because we had a case where a HealthIndicator was being created in the bootstrap context and if spring-boot-starter-web was being used it did not get created if it was disabled in application.properties. However when spring-boot-starter-webflux was used the property had to be put in bootstrap.properties. When you fetch beans from the ApplicationContext as is done in the non-reactive configuration the application hierarchy is not taken into account, so that causes a difference in behavior.

Comment From: wilkinsona

I think we should align the behaviour and that we should do that by changing the non-reactive configuration to match the reactive configuration. Flagging for team attention to check that we agree that that's the right way to go.

Comment From: bclozel

The team discussed this and we'll align the non-reactive behavior with WebFlux.

@ryanjbaxter We're a bit confused by your report - is this about the health indicator bean not being created in the first place in the parent context or how the injection works in this case? It looks like the injection behavior and the configuration property itself are not related here. Do you have a sample we can take a look at?

Comment From: ryanjbaxter

The health indicator was created in the parent context. However (at least from the Java Docs) when you fetch a bean from the ApplicationContext as is done in non-reactive case it will not look in the parent context so any bean that is in the parent context will not be returned.

Here is the issue I was working on that had a sample to reproduce the problem. In this case the sample was using WebFlux, but if you switch it to use spring-boot-starter-web you will notice the HealthIndicator in question is disabled. https://github.com/spring-cloud/spring-cloud-kubernetes/issues/825