Browse Source

Polishing

pull/35808/head
Sam Brannen 1 month ago
parent
commit
93b72fa080
  1. 6
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  2. 10
      spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java

6
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -468,9 +468,9 @@ public class HttpHeaders implements Serializable {
* <p>If the supplied {@code HttpHeaders} instance is a * <p>If the supplied {@code HttpHeaders} instance is a
* {@linkplain #readOnlyHttpHeaders(HttpHeaders) read-only} * {@linkplain #readOnlyHttpHeaders(HttpHeaders) read-only}
* {@code HttpHeaders} wrapper, it will be unwrapped to ensure that the * {@code HttpHeaders} wrapper, it will be unwrapped to ensure that the
* {@code HttpHeaders} instance created by this constructor is mutable. * {@code HttpHeaders} instance created by this constructor is mutable. Once
* Once the writable instance is mutated, the read-only instance is * the writable instance is mutated, the read-only instance is likely to be
* likely to be out of sync and should be discarded. * out of sync and should be discarded.
* @param httpHeaders the headers to expose * @param httpHeaders the headers to expose
* @since 7.0 * @since 7.0
* @see #copyOf(HttpHeaders) * @see #copyOf(HttpHeaders)

10
spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java

@ -32,9 +32,10 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
/** /**
* {@code HttpHeaders} object that can only be read, not written to. * {@code HttpHeaders} variant that can only be read, not written to.
* <p>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. * <p>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 Brian Clozel
* @author Sam Brannen * @author Sam Brannen
@ -44,11 +45,13 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
private static final long serialVersionUID = -8578554704772377436L; private static final long serialVersionUID = -8578554704772377436L;
private @Nullable MediaType cachedContentType; private @Nullable MediaType cachedContentType;
@SuppressWarnings("serial") @SuppressWarnings("serial")
private @Nullable List<MediaType> cachedAccept; private @Nullable List<MediaType> cachedAccept;
ReadOnlyHttpHeaders(MultiValueMap<String, String> headers) { ReadOnlyHttpHeaders(MultiValueMap<String, String> headers) {
super(headers); super(headers);
} }
@ -138,7 +141,6 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
return Collections.unmodifiableSet(super.headerNames()); return Collections.unmodifiableSet(super.headerNames());
} }
@Override @Override
public List<String> put(String key, List<String> value) { public List<String> put(String key, List<String> value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

Loading…
Cancel
Save