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:
Brian Clozel
2018-10-22 14:53:14 +02:00
parent 862dd23975
commit 85262a7932
3 changed files with 18 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
}