From 1d5ffaf30ae40616a765c0d6c0c73de0e947dafa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20P=C3=B3ka?=
Date: Wed, 1 Jun 2022 02:13:32 +0200
Subject: [PATCH] Always construct new exception on error in DefaultWebClient
Always construct new exception on error, otherwise memory leak may
occur due to repeated use of singleton exception.
Closes gh-28550
---
.../web/reactive/function/client/DefaultWebClient.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
index efaf758ef43..42025065cd3 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
@@ -68,7 +68,7 @@ class DefaultWebClient implements WebClient {
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
private static final Mono NO_HTTP_CLIENT_RESPONSE_ERROR = Mono.error(
- new IllegalStateException("The underlying HTTP client completed without emitting a response."));
+ () -> new IllegalStateException("The underlying HTTP client completed without emitting a response."));
private final ExchangeFunction exchangeFunction;