Skip to content

Commit 9ce5a18

Browse files
committed
Ignore null attributes in AbstractView
Consistent with ConcurrentModel and also with treatment of empty values from async attributes. Closes gh-23038
1 parent 9f81484 commit 9ce5a18

File tree

1 file changed

+11
-3
lines changed
  • spring-webflux/src/main/java/org/springframework/web/reactive/result/view

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,19 @@ public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType con
215215
protected Mono<Map<String, Object>> getModelAttributes(
216216
@Nullable Map<String, ?> model, ServerWebExchange exchange) {
217217

218-
int size = (model != null ? model.size() : 0);
219-
Map<String, Object> attributes = new ConcurrentHashMap<>(size);
218+
Map<String, Object> attributes;
220219
if (model != null) {
221-
attributes.putAll(model);
220+
attributes = new ConcurrentHashMap<>(model.size());
221+
for (Map.Entry<String, ?> entry : model.entrySet()) {
222+
if (entry.getValue() != null) {
223+
attributes.put(entry.getKey(), entry.getValue());
224+
}
225+
}
222226
}
227+
else {
228+
attributes = new ConcurrentHashMap<>(0);
229+
}
230+
223231
//noinspection deprecation
224232
return resolveAsyncAttributes(attributes)
225233
.then(resolveAsyncAttributes(attributes, exchange))

0 commit comments

Comments
 (0)