diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java index 4ef79c8cd7..c19a071911 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java @@ -76,6 +76,8 @@ class ConfigurationPropertiesBinder { private final boolean jsr303Present; + private volatile List bindHandlerAdvisors; + private volatile Binder binder; ConfigurationPropertiesBinder(ApplicationContext applicationContext) { @@ -126,6 +128,18 @@ class ConfigurationPropertiesBinder { return handler; } + private List getBindHandlerAdvisors() { + List bindHandlerAdvisors = this.bindHandlerAdvisors; + if (bindHandlerAdvisors == null) { + bindHandlerAdvisors = this.applicationContext + .getBeanProvider(ConfigurationPropertiesBindHandlerAdvisor.class) + .orderedStream() + .toList(); + this.bindHandlerAdvisors = bindHandlerAdvisors; + } + return bindHandlerAdvisors; + } + private IgnoreTopLevelConverterNotFoundBindHandler getHandler() { BoundConfigurationProperties bound = BoundConfigurationProperties.get(this.applicationContext); return (bound != null) @@ -164,12 +178,6 @@ class ConfigurationPropertiesBinder { return new ConfigurationPropertiesJsr303Validator(this.applicationContext, type); } - private List getBindHandlerAdvisors() { - return this.applicationContext.getBeanProvider(ConfigurationPropertiesBindHandlerAdvisor.class) - .orderedStream() - .toList(); - } - private Binder getBinder() { if (this.binder == null) { this.binder = new Binder(getConfigurationPropertySources(), getPropertySourcesPlaceholdersResolver(),