Spring boot actuator autoconfigures ApplicationAvailability bean which is used in AvailabilityProbesAutoConfiguration and AvailabilityHealthContributorAutoConfiguration.
That is awesome since it automatically configures kubernetes probes in separate endpoints (liveness, readiness).
But if i want to replace ApplicationAvailability bean injected in LivenessStateHealthIndicator and ReadinessStateHealthIndicator i have to register ApplicationAvailability as @Primary since it's always registered by ApplicationAvailabilityAutoConfiguration.
This PR prevents auto-registeration of ApplicationAvailability bean when it's already present.
Comment From: wilkinsona
Thanks, @acktsap.
Given that we have the ApplicationAvailability interface and a default implementation of it (ApplicationAvailabilityBean), it feels like a bug to me that you can't (without using @Primary) easily declare your own ApplicationAvailability implementation. That makes it tempting to schedule this for 2.7.x. It could, although I think it's very unlikely, be a breaking change if someone's relying on the current behavior where they end up with both their primary custom implementation and the default implementation co-existing. I can't think why someone would need that behavior though. Flagging for team attention in case I've overlooked something.
Comment From: snicoll
@acktsap thank you for making your first contribution to Spring Boot.
Comment From: nichd147
Hi All i found in my case that after this changes https://github.com/spring-projects/spring-boot/commit/5e95ba84480a1982547a7252392a56c31b909bb3#diff-4520e41b59ccf0379a94bad29e96a802db342fc4a056a570db16ba0821f6b618
ApplicationAvailabilityBean is not being peaked up by DefaultListableBeanFactory because of failing the checking
typeToMatch.isAssignableFrom(beanType)
where typeToMatch - ApplicationListener, beanType - ApplicationAvailability
in 2.7.10 it was typeToMatch - ApplicationListener, beanType - ApplicationAvailabilityBean
and all worked well.
and as a result it's missed during publishing event in org.springframework.boot.context.event.EventPublishingRunListener#started
please check this. to make it works in this version I need to create custom cnfiguration
Comment From: wilkinsona
@dyakovni That has been fixed by https://github.com/spring-projects/spring-boot/issues/35161.