Fix ServletResponseHttpHeaders#get null handling
ServletResponseHttpHeaders#get should be annotated with `@Nullable` and return null instead of a singleton list containing null when there is no content type header. Closes gh-32362
This commit is contained in:
@@ -171,13 +171,15 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> get(Object key) {
|
||||
Assert.isInstanceOf(String.class, key, "Key must be a String-based header name");
|
||||
|
||||
String headerName = (String) key;
|
||||
if (headerName.equalsIgnoreCase(CONTENT_TYPE)) {
|
||||
// Content-Type is written as an override so don't merge
|
||||
return Collections.singletonList(getFirst(headerName));
|
||||
String value = getFirst(headerName);
|
||||
return (value != null ? Collections.singletonList(value) : null);
|
||||
}
|
||||
|
||||
Collection<String> values1 = servletResponse.getHeaders(headerName);
|
||||
|
||||
Reference in New Issue
Block a user