Ignore null attributes in AbstractView
Consistent with ConcurrentModel and also with treatment of empty values from async attributes. Closes gh-23038
This commit is contained in:
parent
9f8148419f
commit
9ce5a18d96
|
@ -215,11 +215,19 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo
|
|||
protected Mono<Map<String, Object>> getModelAttributes(
|
||||
@Nullable Map<String, ?> model, ServerWebExchange exchange) {
|
||||
|
||||
int size = (model != null ? model.size() : 0);
|
||||
Map<String, Object> attributes = new ConcurrentHashMap<>(size);
|
||||
Map<String, Object> attributes;
|
||||
if (model != null) {
|
||||
attributes.putAll(model);
|
||||
attributes = new ConcurrentHashMap<>(model.size());
|
||||
for (Map.Entry<String, ?> entry : model.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
attributes.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
attributes = new ConcurrentHashMap<>(0);
|
||||
}
|
||||
|
||||
//noinspection deprecation
|
||||
return resolveAsyncAttributes(attributes)
|
||||
.then(resolveAsyncAttributes(attributes, exchange))
|
||||
|
|
Loading…
Reference in New Issue