Skip to content

Commit 000b8a6

Browse files
committed
Auto-detect Reactor Netty client in RestClient
Closes gh-33635
1 parent a84a41f commit 000b8a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spring-web/src/main/java/org/springframework/web/client/DefaultRestClientBuilder.java

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
3838
import org.springframework.http.client.JdkClientHttpRequestFactory;
3939
import org.springframework.http.client.JettyClientHttpRequestFactory;
40+
import org.springframework.http.client.ReactorClientHttpRequestFactory;
4041
import org.springframework.http.client.SimpleClientHttpRequestFactory;
4142
import org.springframework.http.client.observation.ClientRequestObservationConvention;
4243
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
@@ -75,6 +76,8 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
7576

7677
private static final boolean jettyClientPresent;
7778

79+
private static final boolean reactorNettyClientPresent;
80+
7881
private static final boolean jdkClientPresent;
7982

8083
// message factories
@@ -99,6 +102,7 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
99102

100103
httpComponentsClientPresent = ClassUtils.isPresent("org.apache.hc.client5.http.classic.HttpClient", loader);
101104
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
105+
reactorNettyClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
102106
jdkClientPresent = ClassUtils.isPresent("java.net.http.HttpClient", loader);
103107

104108
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", loader) &&
@@ -463,6 +467,9 @@ else if (httpComponentsClientPresent) {
463467
else if (jettyClientPresent) {
464468
return new JettyClientHttpRequestFactory();
465469
}
470+
else if (reactorNettyClientPresent) {
471+
return new ReactorClientHttpRequestFactory();
472+
}
466473
else if (jdkClientPresent) {
467474
// java.net.http module might not be loaded, so we can't default to the JDK HttpClient
468475
return new JdkClientHttpRequestFactory();

0 commit comments

Comments
 (0)