Fix NPE in configprops endpoint
This works around spring-projects/spring-framework#28298. The bug means that when a @Configuration class is annotated with @ConfigurationProperties any bean defined by a static @Bean method is considered to be annotated with @ConfigurationProperties. See gh-30068
This commit is contained in:
parent
e3859fadd6
commit
a1fe05f40b
|
|
@ -121,7 +121,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
|||
|
||||
@ReadOperation
|
||||
public ApplicationConfigurationProperties configurationProperties() {
|
||||
return extract(this.context, (bean) -> true);
|
||||
return extract(this.context, (bean) -> bean != null);
|
||||
}
|
||||
|
||||
@ReadOperation
|
||||
|
|
|
|||
|
|
@ -144,7 +144,13 @@ public final class ConfigurationPropertiesBean {
|
|||
}
|
||||
Map<String, ConfigurationPropertiesBean> propertiesBeans = new LinkedHashMap<>();
|
||||
applicationContext.getBeansWithAnnotation(ConfigurationProperties.class)
|
||||
.forEach((beanName, bean) -> propertiesBeans.put(beanName, get(applicationContext, bean, beanName)));
|
||||
.forEach((beanName, bean) -> {
|
||||
ConfigurationPropertiesBean propertiesBean = get(applicationContext, bean, beanName);
|
||||
if (propertiesBean == null) { //ignore for null
|
||||
return;
|
||||
}
|
||||
propertiesBeans.put(beanName,propertiesBean);
|
||||
});
|
||||
return propertiesBeans;
|
||||
}
|
||||
|
||||
|
|
@ -158,6 +164,9 @@ public final class ConfigurationPropertiesBean {
|
|||
try {
|
||||
Object bean = beanFactory.getBean(beanName);
|
||||
ConfigurationPropertiesBean propertiesBean = get(applicationContext, bean, beanName);
|
||||
if (propertiesBean == null) { //ignore for null
|
||||
continue;
|
||||
}
|
||||
propertiesBeans.put(beanName, propertiesBean);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue