Merge branch '3.1.x'

Closes gh-36521
pull/36537/head
Stephane Nicoll 1 year ago
commit 771a98b192

@ -39,31 +39,22 @@ import org.springframework.boot.origin.Origin;
class ConfigDataLocationBindHandler extends AbstractBindHandler {
@Override
@SuppressWarnings("unchecked")
public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) {
if (result instanceof ConfigDataLocation location) {
return withOrigin(context, location);
}
if (result instanceof List) {
List<Object> list = ((List<Object>) result).stream()
if (result instanceof List<?> list) {
return list.stream()
.filter(Objects::nonNull)
.map((element) -> (element instanceof ConfigDataLocation location) ? withOrigin(context, location)
: element)
.collect(Collectors.toCollection(ArrayList::new));
for (int i = 0; i < list.size(); i++) {
Object element = list.get(i);
if (element instanceof ConfigDataLocation location) {
list.set(i, withOrigin(context, location));
}
}
return list;
}
if (result instanceof ConfigDataLocation[] unfilteredLocations) {
ConfigDataLocation[] locations = Arrays.stream(unfilteredLocations)
return Arrays.stream(unfilteredLocations)
.filter(Objects::nonNull)
.map((element) -> withOrigin(context, element))
.toArray(ConfigDataLocation[]::new);
for (int i = 0; i < locations.length; i++) {
locations[i] = withOrigin(context, locations[i]);
}
return locations;
}
return result;
}

Loading…
Cancel
Save