Restore original readOnlyHttpHeaders signature for binary compatibility

Closes gh-25034
This commit is contained in:
Juergen Hoeller 2020-06-06 13:14:47 +02:00
parent fbeecf3bf8
commit ad5710c1d1
1 changed files with 10 additions and 6 deletions

View File

@ -385,7 +385,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* An empty {@code HttpHeaders} instance (immutable).
* @since 5.0
*/
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new HttpHeaders(new LinkedMultiValueMap<>(0)));
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new LinkedMultiValueMap<>());
/**
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
@ -1769,17 +1769,21 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers.
* Apply a read-only {@code HttpHeaders} wrapper around the given headers,
* if necessary.
* @param headers the headers to expose
* @return a read-only variant of the headers, or the original headers as-is
*/
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
Assert.notNull(headers, "HttpHeaders must not be null");
return (headers instanceof ReadOnlyHttpHeaders ?
(HttpHeaders) headers : new ReadOnlyHttpHeaders(headers));
return (headers instanceof ReadOnlyHttpHeaders ? headers : new ReadOnlyHttpHeaders(headers.headers));
}
/**
* Remove any read-only wrapper that may have been previously applied around
* the given headers via {@link #readOnlyHttpHeaders(MultiValueMap)}.
* the given headers via {@link #readOnlyHttpHeaders(HttpHeaders)}.
* @param headers the headers to expose
* @return a writable variant of the headers, or the original headers as-is
* @since 5.1.1
*/
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {