From 510436bae9a9c2611b95a5b7b0d9be779dbbe742 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 7 Jun 2017 17:55:51 +0200 Subject: [PATCH] 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` 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. --- .../function/client/DefaultClientRequestBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java index d0f8456f3c..451c58c047 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java @@ -73,7 +73,12 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @Override public ClientRequest.Builder headers(HttpHeaders headers) { - this.headers.putAll(headers); + for (Map.Entry> entry : headers.entrySet()) { + String headerName = entry.getKey(); + for (String headerValue : entry.getValue()) { + this.headers.add(headerName, headerValue); + } + } return this; }