Skip to content

Commit

Permalink
Restore original readOnlyHttpHeaders signature for binary compatibility
Browse files Browse the repository at this point in the history
Closes gh-25034
  • Loading branch information
jhoeller committed Jun 6, 2020
1 parent fbeecf3 commit ad5710c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions spring-web/src/main/java/org/springframework/http/HttpHeaders.java
Expand Up @@ -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".
Expand Down Expand Up @@ -1769,17 +1769,21 @@ public String toString() {


/**
* 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) {
Expand Down

0 comments on commit ad5710c

Please sign in to comment.