From 9ce5a18d96deb1207889ade128210acfb6adaeaa Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 7 Jun 2019 16:25:47 -0400 Subject: [PATCH] Ignore null attributes in AbstractView Consistent with ConcurrentModel and also with treatment of empty values from async attributes. Closes gh-23038 --- .../web/reactive/result/view/AbstractView.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java index a4d0801e5f..4234df9f31 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java +++ b/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> getModelAttributes( @Nullable Map model, ServerWebExchange exchange) { - int size = (model != null ? model.size() : 0); - Map attributes = new ConcurrentHashMap<>(size); + Map attributes; if (model != null) { - attributes.putAll(model); + attributes = new ConcurrentHashMap<>(model.size()); + for (Map.Entry 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))