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 { @@ -468,9 +468,9 @@ public class HttpHeaders implements Serializable {
* <p>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)

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

@ -32,9 +32,10 @@ import org.springframework.util.CollectionUtils; @@ -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.
* <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.
* {@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 if it is mutated at runtime.
*
* @author Brian Clozel
* @author Sam Brannen
@ -44,11 +45,13 @@ class ReadOnlyHttpHeaders extends HttpHeaders { @@ -44,11 +45,13 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
private static final long serialVersionUID = -8578554704772377436L;
private @Nullable MediaType cachedContentType;
@SuppressWarnings("serial")
private @Nullable List<MediaType> cachedAccept;
ReadOnlyHttpHeaders(MultiValueMap<String, String> headers) {
super(headers);
}
@ -138,7 +141,6 @@ class ReadOnlyHttpHeaders extends HttpHeaders { @@ -138,7 +141,6 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
return Collections.unmodifiableSet(super.headerNames());
}
@Override
public List<String> put(String key, List<String> value) {
throw new UnsupportedOperationException();

Loading…
Cancel
Save