Skip to content

Commit ad5710c

Browse files
committed
Restore original readOnlyHttpHeaders signature for binary compatibility
Closes gh-25034
1 parent fbeecf3 commit ad5710c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
385385
* An empty {@code HttpHeaders} instance (immutable).
386386
* @since 5.0
387387
*/
388-
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new HttpHeaders(new LinkedMultiValueMap<>(0)));
388+
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new LinkedMultiValueMap<>());
389389

390390
/**
391391
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
@@ -1769,17 +1769,21 @@ public String toString() {
17691769

17701770

17711771
/**
1772-
* Apply a read-only {@code HttpHeaders} wrapper around the given headers.
1772+
* Apply a read-only {@code HttpHeaders} wrapper around the given headers,
1773+
* if necessary.
1774+
* @param headers the headers to expose
1775+
* @return a read-only variant of the headers, or the original headers as-is
17731776
*/
1774-
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
1777+
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
17751778
Assert.notNull(headers, "HttpHeaders must not be null");
1776-
return (headers instanceof ReadOnlyHttpHeaders ?
1777-
(HttpHeaders) headers : new ReadOnlyHttpHeaders(headers));
1779+
return (headers instanceof ReadOnlyHttpHeaders ? headers : new ReadOnlyHttpHeaders(headers.headers));
17781780
}
17791781

17801782
/**
17811783
* Remove any read-only wrapper that may have been previously applied around
1782-
* the given headers via {@link #readOnlyHttpHeaders(MultiValueMap)}.
1784+
* the given headers via {@link #readOnlyHttpHeaders(HttpHeaders)}.
1785+
* @param headers the headers to expose
1786+
* @return a writable variant of the headers, or the original headers as-is
17831787
* @since 5.1.1
17841788
*/
17851789
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {

0 commit comments

Comments
 (0)