diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index f545c1ed151..aca2750dc8e 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -468,9 +468,9 @@ public class HttpHeaders implements Serializable { *

If the supplied {@code HttpHeaders} instance is a * {@linkplain #readOnlyHttpHeaders(HttpHeaders) read-only} * {@code HttpHeaders} wrapper, it will be unwrapped to ensure that the - * {@code HttpHeaders} instance created by this constructor is mutable. - * Once the writable instance is mutated, the read-only instance is - * likely to be out of sync and should be discarded. + * {@code HttpHeaders} instance created by this constructor is mutable. Once + * the writable instance is mutated, the read-only instance is likely to be + * out of sync and should be discarded. * @param httpHeaders the headers to expose * @since 7.0 * @see #copyOf(HttpHeaders) diff --git a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java index 8eeabf1a63d..87abd29ae56 100644 --- a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java @@ -32,9 +32,10 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.MultiValueMap; /** - * {@code HttpHeaders} object that can only be read, not written to. - *

This caches the parsed representations of the "Accept" and "Content-Type" headers - * and will get out of sync with the backing map it is mutated at runtime. + * {@code HttpHeaders} variant that can only be read, not written to. + * + *

This caches the parsed representations of the "Accept" and "Content-Type" + * headers and will get out of sync with the backing map if it is mutated at runtime. * * @author Brian Clozel * @author Sam Brannen @@ -44,11 +45,13 @@ class ReadOnlyHttpHeaders extends HttpHeaders { private static final long serialVersionUID = -8578554704772377436L; + private @Nullable MediaType cachedContentType; @SuppressWarnings("serial") private @Nullable List cachedAccept; + ReadOnlyHttpHeaders(MultiValueMap headers) { super(headers); } @@ -138,7 +141,6 @@ class ReadOnlyHttpHeaders extends HttpHeaders { return Collections.unmodifiableSet(super.headerNames()); } - @Override public List put(String key, List value) { throw new UnsupportedOperationException();