diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientRequestException.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientRequestException.java index 8e8c5c3e334..6b4d9c39a26 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientRequestException.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientRequestException.java @@ -17,6 +17,8 @@ package org.springframework.web.reactive.function.client; import java.net.URI; +import java.util.List; +import java.util.Map; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -56,7 +58,11 @@ public class WebClientRequestException extends WebClientException { */ private static HttpHeaders copy(HttpHeaders headers) { HttpHeaders result = new HttpHeaders(); - result.putAll(headers); + for (Map.Entry> entry : headers.entrySet()) { + for (String value : entry.getValue()) { + result.add(entry.getKey(), value); + } + } return result; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java index 62b5a7b3afb..c449cd35d45 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java @@ -18,6 +18,8 @@ package org.springframework.web.reactive.function.client; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; @@ -47,7 +49,7 @@ public class WebClientResponseException extends WebClientException { private final Charset responseCharset; @Nullable - private final HttpRequest request; + private transient final HttpRequest request; /** @@ -112,7 +114,11 @@ public class WebClientResponseException extends WebClientException { } else { HttpHeaders result = new HttpHeaders(); - result.putAll(headers); + for (Map.Entry> entry : headers.entrySet()) { + for (String value : entry.getValue()) { + result.add(entry.getKey(), value); + } + } return result; } }