Skip to content

Commit a54618b

Browse files
committed
Simplify HttpHeaders(HttpHeaders) constructor
1 parent d37030b commit a54618b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,9 @@ public HttpHeaders(MultiValueMap<String, String> headers) {
477477
*/
478478
public HttpHeaders(HttpHeaders httpHeaders) {
479479
Assert.notNull(httpHeaders, "HttpHeaders must not be null");
480-
if (httpHeaders == EMPTY) {
481-
this.headers = CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH));
482-
}
483-
else {
484-
while (httpHeaders.headers instanceof HttpHeaders wrapped) {
485-
httpHeaders = wrapped;
486-
}
487-
this.headers = httpHeaders.headers;
488-
}
480+
this.headers = (httpHeaders == EMPTY ?
481+
CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)) :
482+
unwrap(httpHeaders));
489483
}
490484

491485
/**

0 commit comments

Comments
 (0)