Filter out null WebSocketSession attributes

Closes gh-29315
This commit is contained in:
rstoyanchev
2022-11-11 11:20:18 +00:00
parent db9e89fba9
commit 8ade083a05
3 changed files with 21 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,9 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
*/
public AbstractWebSocketSession(@Nullable Map<String, Object> attributes) {
if (attributes != null) {
this.attributes.putAll(attributes);
attributes.entrySet().stream()
.filter(entry -> (entry.getKey() != null && entry.getValue() != null))
.forEach(entry -> this.attributes.put(entry.getKey(), entry.getValue()));
}
}