Return previous value in UndertowHeadersAdapter's remove() method
Prior to this commit, UndertowHeadersAdapter's remove() method violated the java.util.Map contract by always returning null. This commit fixes this by returning the previous list stored under the specified key, and otherwise returning null if no previous value was present. Closes gh-27592
This commit is contained in:
parent
e5475d698a
commit
a603779f33
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.http.server.reactive;
|
||||
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -36,6 +37,7 @@ import org.springframework.util.MultiValueMap;
|
|||
* {@code MultiValueMap} implementation for wrapping Undertow HTTP headers.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
* @since 5.1.1
|
||||
*/
|
||||
class UndertowHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
@ -131,7 +133,10 @@ class UndertowHeadersAdapter implements MultiValueMap<String, String> {
|
|||
@Nullable
|
||||
public List<String> remove(Object key) {
|
||||
if (key instanceof String) {
|
||||
this.headers.remove((String) key);
|
||||
Collection<String> removed = this.headers.remove((String) key);
|
||||
if (removed != null) {
|
||||
return new ArrayList<>(removed);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue