Skip to content

Commit 804955f

Browse files
committed
Removed checking for descendant properties, because otherwise fallback
properties must always be from the same namespace (spring-projects#7986).
1 parent ffd5cdd commit 804955f

File tree

1 file changed

+4
-11
lines changed
  • spring-boot/src/main/java/org/springframework/boot/context/properties/bind

1 file changed

+4
-11
lines changed

spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ private <T> T handleBindResult(ConfigurationPropertyName name, Bindable<T> targe
209209
result = handler.onSuccess(name, target, context, result);
210210
result = convert(result, target);
211211
}
212+
else {
213+
result = handler.onNull(name, target, context);
214+
}
212215
handler.onFinish(name, target, context, result);
213216
return convert(result, target);
214217
}
@@ -237,9 +240,6 @@ private <T> T convert(Object value, Bindable<T> target) {
237240
private <T> Object bindObject(ConfigurationPropertyName name, Bindable<T> target,
238241
BindHandler handler, Context context) throws Exception {
239242
ConfigurationProperty property = findProperty(name, context);
240-
if (property == null && containsNoDescendantOf(context.streamSources(), name)) {
241-
return null;
242-
}
243243
AggregateBinder<?> aggregateBinder = getAggregateBinder(target, context);
244244
if (aggregateBinder != null) {
245245
return bindAggregate(name, target, handler, context, aggregateBinder);
@@ -292,8 +292,7 @@ private <T> Object bindProperty(ConfigurationPropertyName name, Bindable<T> targ
292292

293293
private Object bindBean(ConfigurationPropertyName name, Bindable<?> target,
294294
BindHandler handler, Context context) {
295-
if (containsNoDescendantOf(context.streamSources(), name)
296-
|| isUnbindableBean(name, target, context)) {
295+
if (isUnbindableBean(name, target, context)) {
297296
return null;
298297
}
299298
BeanPropertyBinder propertyBinder = (propertyName, propertyTarget) -> bind(
@@ -324,12 +323,6 @@ private boolean isUnbindableBean(ConfigurationPropertyName name, Bindable<?> tar
324323
return packageName.startsWith("java.");
325324
}
326325

327-
private boolean containsNoDescendantOf(Stream<ConfigurationPropertySource> sources,
328-
ConfigurationPropertyName name) {
329-
return sources.allMatch(
330-
(s) -> s.containsDescendantOf(name) == ConfigurationPropertyState.ABSENT);
331-
}
332-
333326
/**
334327
* Create a new {@link Binder} instance from the specified environment.
335328
* @param environment the environment source (must have attached

0 commit comments

Comments
 (0)