From 32f128b6ba118ea42f6648cda94ed1de7afa75aa Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Wed, 30 Aug 2023 16:37:13 +0100 Subject: [PATCH] Add create static factory method to WebClientAdapter Closes gh-31120 --- .../function/client/support/WebClientAdapter.java | 13 +++++++++++++ .../client/support/WebClientAdapterTests.java | 2 +- .../support/WebClientHttpServiceProxyKotlinTests.kt | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java index 3c43c2be270..1459a4805e6 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java @@ -138,7 +138,20 @@ public final class WebClientAdapter extends AbstractReactorHttpExchangeAdapter { * Create a {@link WebClientAdapter} for the given {@code WebClient} instance. * @param webClient the client to use * @return the created adapter instance + * @since 6.1 */ + public static WebClientAdapter create(WebClient webClient) { + return new WebClientAdapter(webClient); + } + + /** + * Create a {@link WebClientAdapter} for the given {@code WebClient} instance. + * @param webClient the client to use + * @return the created adapter instance + * @deprecated in favor of {@link #create(WebClient)} aligning with other adapter + * implementations; to be removed in 6.2. + */ + @Deprecated(since = "6.1", forRemoval = true) public static WebClientAdapter forClient(WebClient webClient) { return new WebClientAdapter(webClient); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java index 42bbc086591..52981b73bf5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java @@ -163,7 +163,7 @@ public class WebClientAdapterTests { } private Service initService(WebClient webClient) { - WebClientAdapter adapter = WebClientAdapter.forClient(webClient); + WebClientAdapter adapter = WebClientAdapter.create(webClient); return HttpServiceProxyFactory.builderFor(adapter).build().createClient(Service.class); } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyKotlinTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyKotlinTests.kt index 7ca2816cc7d..32c48f8f342 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyKotlinTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyKotlinTests.kt @@ -128,7 +128,7 @@ class KotlinWebClientHttpServiceProxyTests { } private fun initHttpService(webClient: WebClient): TestHttpService { - val adapter = WebClientAdapter.forClient(webClient) + val adapter = WebClientAdapter.create(webClient) return HttpServiceProxyFactory.builderFor(adapter).build().createClient() }