From e8f71ab5efe228b143abe651477631ff2c538c81 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 6 Feb 2025 14:37:16 +0100 Subject: [PATCH] Simplify HttpHeaders constructor As of gh-33913, `HttpHeaders` does not implement the `MultiValueMap` contract anymore, so we can take this opportunity to simplify one of the constructors to not consider that the argument could be an `HttpHeaders` instance. This case is already covered by the other constructor. See gh-33913 --- .../java/org/springframework/http/HttpHeaders.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index c9dc894eeca..ee4d794e0e4 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -455,18 +455,7 @@ public class HttpHeaders implements Serializable { */ public HttpHeaders(MultiValueMap headers) { Assert.notNull(headers, "MultiValueMap must not be null"); - if (headers == EMPTY) { - this.headers = CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)); - } - else if (headers instanceof HttpHeaders httpHeaders) { - while (httpHeaders.headers instanceof HttpHeaders wrapped) { - httpHeaders = wrapped; - } - this.headers = httpHeaders.headers; - } - else { - this.headers = headers; - } + this.headers = headers; } /**