Nullability refinements and related polishing

This commit is contained in:
Juergen Hoeller
2021-02-14 17:57:32 +01:00
parent 99a1388bbd
commit df977a2fd2
9 changed files with 32 additions and 16 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
@@ -147,10 +148,12 @@ class JettyClientHttpResponse implements ClientHttpResponse {
HttpHeaders headers = new HttpHeaders();
Iterable<?> iterator = (Iterable<?>)
ReflectionUtils.invokeMethod(getHeadersMethod, response.getResponse());
Assert.notNull(iterator, "Iterator must not be null");
for (Object field : iterator) {
headers.add(
(String) ReflectionUtils.invokeMethod(getNameMethod, field),
(String) ReflectionUtils.invokeMethod(getValueMethod, field));
String name = (String) ReflectionUtils.invokeMethod(getNameMethod, field);
Assert.notNull(name, "Header name must not be null");
String value = (String) ReflectionUtils.invokeMethod(getValueMethod, field);
headers.add(name, value);
}
return headers;
}

View File

@@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
*
* @author Arjen Poutsma
* @author Juergen Hoeller
* @author Rossen Stoyanchev
* @since 3.0
* @param <T> the converted object type
*/
@@ -67,8 +68,8 @@ public interface HttpMessageConverter<T> {
/**
* Return the list of media types supported by this converter for the given
* class. The list may differ from {@link #getSupportedMediaTypes()} if the
* converter doesn't support given Class or if it support it only for a
* subset of media types.
* converter does not support the given Class or if it supports it only for
* a subset of media types.
* @param clazz the type of class to check
* @return the list of media types supported for the given class
* @since 5.3.4