Skip to content

Commit 510436b

Browse files
committed
Copy header values instead of header lists in DefaultClientRequestBuilder
This commit changes the `headers(HttpHeaders)` method in DefaultClientRequestBuilder so that it copies the individual header values instead of using the `List<String>` value directly. The reason for this change is that the list of values can be immutable, and adding additional values after that could result in UnsupportedOperationExceptions.
1 parent a0bce61 commit 510436b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ public ClientRequest.Builder header(String headerName, String... headerValues) {
7373

7474
@Override
7575
public ClientRequest.Builder headers(HttpHeaders headers) {
76-
this.headers.putAll(headers);
76+
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
77+
String headerName = entry.getKey();
78+
for (String headerValue : entry.getValue()) {
79+
this.headers.add(headerName, headerValue);
80+
}
81+
}
7782
return this;
7883
}
7984

0 commit comments

Comments
 (0)