Fix Map.put contract for HeadersAdapter impl.
This commit fixes the `Map.put` contract for both Reactor Netty and Tomcat specific `HeadersAdapter` implementations. Issue: SPR-17415
This commit is contained in:
@@ -124,7 +124,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public List<String> put(String key, @Nullable List<String> value) {
|
||||
List<String> previousValues = this.headers.getAll(key);
|
||||
this.headers.add(key, value);
|
||||
this.headers.set(key, value);
|
||||
return previousValues;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ class TomcatHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Nullable
|
||||
public List<String> put(String key, List<String> value) {
|
||||
List<String> previousValues = get(key);
|
||||
this.headers.removeHeader(key);
|
||||
value.forEach(v -> this.headers.addValue(key).setString(v));
|
||||
return previousValues;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user