Browse Source

Ignore null attributes in AbstractView

Consistent with ConcurrentModel and also with treatment of empty values
from async attributes.

Closes gh-23038
pull/23837/head
Rossen Stoyanchev 6 years ago
parent
commit
9ce5a18d96
  1. 14
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java

14
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java

@ -215,11 +215,19 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo
protected Mono<Map<String, Object>> getModelAttributes( protected Mono<Map<String, Object>> getModelAttributes(
@Nullable Map<String, ?> model, ServerWebExchange exchange) { @Nullable Map<String, ?> model, ServerWebExchange exchange) {
int size = (model != null ? model.size() : 0); Map<String, Object> attributes;
Map<String, Object> attributes = new ConcurrentHashMap<>(size);
if (model != null) { 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 //noinspection deprecation
return resolveAsyncAttributes(attributes) return resolveAsyncAttributes(attributes)
.then(resolveAsyncAttributes(attributes, exchange)) .then(resolveAsyncAttributes(attributes, exchange))

Loading…
Cancel
Save