Skip to content

Commit

Permalink
Refine naming consistency for HttpRequestFactories
Browse files Browse the repository at this point in the history
This commit renames three classes to improve naming consistency within the Spring Framework:
- `ReactorNettyClientRequestFactory` -> `ReactorClientHttpRequestFactory`
- `ReactorClientHttpConnector` -> `ReactorNettyClientHttpConnector`
- `HttpComponentsClientHttpRequestFactory` -> `HttpComponentsClientRequestFactory`

These changes align the class names with others in the project, reducing redundancy and improving clarity. This update affects 31 files.

Issue: spring-projects#33382
  • Loading branch information
Torres-09 committed Aug 20, 2024
1 parent 4a099d2 commit 3d6e78b
Show file tree
Hide file tree
Showing 31 changed files with 98 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
import org.springframework.http.client.reactive.JdkClientHttpConnector;
import org.springframework.http.client.reactive.JettyClientHttpConnector;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.client.reactive.ReactorNettyClientHttpConnector;
import org.springframework.http.client.reactive.ReactorNetty2ClientHttpConnector;
import org.springframework.http.codec.ClientCodecConfigurer;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -314,7 +314,7 @@ public WebTestClient build() {

private static ClientHttpConnector initConnector() {
if (reactorNettyClientPresent) {
return new ReactorClientHttpConnector();
return new ReactorNettyClientHttpConnector();
}
else if (reactorNetty2ClientPresent) {
return new ReactorNetty2ClientHttpConnector();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,13 +43,13 @@
* {@link ClientHttpRequest} implementation based on
* Apache HttpComponents HttpClient.
*
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
* <p>Created via the {@link HttpComponentsClientRequestFactory}.
*
* @author Oleg Kalnichevski
* @author Arjen Poutsma
* @author Juergen Hoeller
* @since 3.1
* @see HttpComponentsClientHttpRequestFactory#createRequest(URI, HttpMethod)
* @see HttpComponentsClientRequestFactory#createRequest(URI, HttpMethod)
*/
final class HttpComponentsClientHttpRequest extends AbstractStreamingClientHttpRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* @author Juergen Hoeller
* @since 3.1
*/
public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequestFactory, DisposableBean {
public class HttpComponentsClientRequestFactory implements ClientHttpRequestFactory, DisposableBean {

private HttpClient httpClient;

Expand All @@ -78,7 +78,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
* Create a new instance of the {@code HttpComponentsClientHttpRequestFactory}
* with a default {@link HttpClient} based on system properties.
*/
public HttpComponentsClientHttpRequestFactory() {
public HttpComponentsClientRequestFactory() {
this.httpClient = HttpClients.createSystem();
}

Expand All @@ -87,7 +87,7 @@ public HttpComponentsClientHttpRequestFactory() {
* with the given {@link HttpClient} instance.
* @param httpClient the HttpClient instance to use for this request factory
*/
public HttpComponentsClientHttpRequestFactory(HttpClient httpClient) {
public HttpComponentsClientRequestFactory(HttpClient httpClient) {
this.httpClient = httpClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
* @author Sebastien Deleuze
* @since 6.1
*/
public class ReactorNettyClientRequestFactory implements ClientHttpRequestFactory, SmartLifecycle {
public class ReactorClientHttpRequestFactory implements ClientHttpRequestFactory, SmartLifecycle {

private static final Log logger = LogFactory.getLog(ReactorNettyClientRequestFactory.class);
private static final Log logger = LogFactory.getLog(ReactorClientHttpRequestFactory.class);

private static final Function<HttpClient, HttpClient> defaultInitializer = client -> client.compress(true);

Expand Down Expand Up @@ -73,7 +73,7 @@ public class ReactorNettyClientRequestFactory implements ClientHttpRequestFactor
* Create a new instance of the {@code ReactorNettyClientRequestFactory}
* with a default {@link HttpClient} that has compression enabled.
*/
public ReactorNettyClientRequestFactory() {
public ReactorClientHttpRequestFactory() {
this.httpClient = defaultInitializer.apply(HttpClient.create());
this.resourceFactory = null;
this.mapper = null;
Expand All @@ -84,7 +84,7 @@ public ReactorNettyClientRequestFactory() {
* based on the given {@link HttpClient}.
* @param httpClient the client to base on
*/
public ReactorNettyClientRequestFactory(HttpClient httpClient) {
public ReactorClientHttpRequestFactory(HttpClient httpClient) {
Assert.notNull(httpClient, "HttpClient must not be null");
this.httpClient = httpClient;
this.resourceFactory = null;
Expand All @@ -108,7 +108,7 @@ public ReactorNettyClientRequestFactory(HttpClient httpClient) {
* @param resourceFactory the resource factory to obtain the resources from
* @param mapper a mapper for further initialization of the created client
*/
public ReactorNettyClientRequestFactory(ReactorResourceFactory resourceFactory, Function<HttpClient, HttpClient> mapper) {
public ReactorClientHttpRequestFactory(ReactorResourceFactory resourceFactory, Function<HttpClient, HttpClient> mapper) {
this.resourceFactory = resourceFactory;
this.mapper = mapper;
if (resourceFactory.isRunning()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,7 @@
* @author Juergen Hoeller
* @since 3.0
* @see java.net.HttpURLConnection
* @see HttpComponentsClientHttpRequestFactory
* @see HttpComponentsClientRequestFactory
*/
public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ protected void applyCookies() {
/**
* Saves the {@link #getAttributes() request attributes} to the
* {@link reactor.netty.channel.ChannelOperations#channel() channel} as a single map
* attribute under the key {@link ReactorClientHttpConnector#ATTRIBUTES_KEY}.
* attribute under the key {@link ReactorNettyClientHttpConnector#ATTRIBUTES_KEY}.
*/
@Override
protected void applyAttributes() {
if (!getAttributes().isEmpty()) {
((ChannelOperations<?, ?>) this.request).channel()
.attr(ReactorClientHttpConnector.ATTRIBUTES_KEY).set(getAttributes());
.attr(ReactorNettyClientHttpConnector.ATTRIBUTES_KEY).set(getAttributes());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -161,7 +161,7 @@ private static String getSameSite(Cookie cookie) {
}

/**
* Called by {@link ReactorClientHttpConnector} when a cancellation is detected
* Called by {@link ReactorNettyClientHttpConnector} when a cancellation is detected
* but the content has not been subscribed to. If the subscription never
* materializes then the content will remain not drained. Or it could still
* materialize if the cancellation happened very early, or the response
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,7 @@
/**
* Reactor Netty 2 (Netty 5) implementation of {@link ClientHttpConnector}.
*
* <p>This class is based on {@link ReactorClientHttpConnector}.
* <p>This class is based on {@link ReactorNettyClientHttpConnector}.
*
* @author Violeta Georgieva
* @since 6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @since 5.0
* @see reactor.netty.http.client.HttpClient
*/
public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLifecycle {
public class ReactorNettyClientHttpConnector implements ClientHttpConnector, SmartLifecycle {

/**
* Channel attribute key under which {@code WebClient} request attributes are stored as a Map.
Expand All @@ -59,7 +59,7 @@ public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLif
public static final AttributeKey<Map<String, Object>> ATTRIBUTES_KEY =
AttributeKey.valueOf(ReactorClientHttpRequest.class.getName() + ".ATTRIBUTES");

private static final Log logger = LogFactory.getLog(ReactorClientHttpConnector.class);
private static final Log logger = LogFactory.getLog(ReactorNettyClientHttpConnector.class);

private static final Function<HttpClient, HttpClient> defaultInitializer = client -> client.compress(true);

Expand All @@ -82,7 +82,7 @@ public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLif
* Default constructor. Initializes {@link HttpClient} via:
* <pre class="code">HttpClient.create().compress(true)</pre>
*/
public ReactorClientHttpConnector() {
public ReactorNettyClientHttpConnector() {
this.httpClient = defaultInitializer.apply(HttpClient.create());
this.resourceFactory = null;
this.mapper = null;
Expand All @@ -93,7 +93,7 @@ public ReactorClientHttpConnector() {
* @param httpClient the client to use
* @since 5.1
*/
public ReactorClientHttpConnector(HttpClient httpClient) {
public ReactorNettyClientHttpConnector(HttpClient httpClient) {
Assert.notNull(httpClient, "HttpClient is required");
this.httpClient = httpClient;
this.resourceFactory = null;
Expand All @@ -118,7 +118,7 @@ public ReactorClientHttpConnector(HttpClient httpClient) {
* @param mapper a mapper for further initialization of the created client
* @since 5.1
*/
public ReactorClientHttpConnector(ReactorResourceFactory resourceFactory, Function<HttpClient, HttpClient> mapper) {
public ReactorNettyClientHttpConnector(ReactorResourceFactory resourceFactory, Function<HttpClient, HttpClient> mapper) {
this.resourceFactory = resourceFactory;
this.mapper = mapper;
if (resourceFactory.isRunning()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestInitializer;
import org.springframework.http.client.HttpComponentsClientRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -66,7 +67,7 @@ public abstract class HttpAccessor {
* Configure the Apache HttpComponents or OkHttp request factory to enable PATCH.</b>
* @see #createRequest(URI, HttpMethod)
* @see SimpleClientHttpRequestFactory
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
* @see HttpComponentsClientRequestFactory
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/
public void setRequestFactory(ClientHttpRequestFactory requestFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestInitializer;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientRequestFactory;
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
Expand Down Expand Up @@ -443,7 +443,7 @@ private ClientHttpRequestFactory initRequestFactory() {
return this.requestFactory;
}
else if (httpComponentsClientPresent) {
return new HttpComponentsClientHttpRequestFactory();
return new HttpComponentsClientRequestFactory();
}
else if (jettyClientPresent) {
return new JettyClientHttpRequestFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.springframework.http.client.ClientHttpRequestInitializer;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsClientRequestFactory;
import org.springframework.http.client.observation.ClientRequestObservationConvention;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -385,7 +386,7 @@ Builder defaultStatusHandler(Predicate<HttpStatusCode> statusPredicate,
* for plugging in and/or customizing options of the underlying HTTP
* client library (e.g. SSL).
* <p>If no request factory is specified, {@code RestClient} uses
* {@linkplain org.springframework.http.client.HttpComponentsClientHttpRequestFactory Apache Http Client},
* {@linkplain HttpComponentsClientRequestFactory Apache Http Client},
* {@linkplain org.springframework.http.client.JettyClientHttpRequestFactory Jetty Http Client}
* if available on the classpath, and defaults to the
* {@linkplain org.springframework.http.client.JdkClientHttpRequestFactory JDK HttpClient}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsClientRequestFactory;
import org.springframework.http.client.observation.ClientHttpObservationDocumentation;
import org.springframework.http.client.observation.ClientRequestObservationContext;
import org.springframework.http.client.observation.ClientRequestObservationConvention;
Expand Down Expand Up @@ -241,7 +242,7 @@ else if (kotlinSerializationCborPresent) {
* Create a new instance of the {@link RestTemplate} based on the given {@link ClientHttpRequestFactory}.
* @param requestFactory the HTTP request factory to use
* @see org.springframework.http.client.SimpleClientHttpRequestFactory
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
* @see HttpComponentsClientRequestFactory
*/
public RestTemplate(ClientHttpRequestFactory requestFactory) {
this();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryT

@Override
protected ClientHttpRequestFactory createRequestFactory() {
return new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory());
return new BufferingClientHttpRequestFactory(new HttpComponentsClientRequestFactory());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
* @author Stephane Nicoll
* @author Brian Clozel
*/
class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
class HttpComponentsClientRequestFactoryTests extends AbstractHttpRequestFactoryTests {

@Override
protected ClientHttpRequestFactory createRequestFactory() {
return new HttpComponentsClientHttpRequestFactory();
return new HttpComponentsClientRequestFactory();
}

@Override
Expand All @@ -63,7 +63,7 @@ void httpMethods() throws Exception {
@SuppressWarnings("deprecation")
void assertCustomConfig() throws Exception {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpComponentsClientHttpRequestFactory hrf = new HttpComponentsClientHttpRequestFactory(httpClient);
HttpComponentsClientRequestFactory hrf = new HttpComponentsClientRequestFactory(httpClient);
hrf.setConnectTimeout(1234);
hrf.setConnectionRequestTimeout(4321);

Expand All @@ -88,7 +88,7 @@ void defaultSettingsOfHttpClientMergedOnExecutorCustomization() throws Exception
Configurable configurable = (Configurable) client;
given(configurable.getConfig()).willReturn(defaultConfig);

HttpComponentsClientHttpRequestFactory hrf = new HttpComponentsClientHttpRequestFactory(client);
HttpComponentsClientRequestFactory hrf = new HttpComponentsClientRequestFactory(client);
assertThat(retrieveRequestConfig(hrf)).as("Default client configuration is expected").isSameAs(defaultConfig);

hrf.setConnectionRequestTimeout(4567);
Expand All @@ -111,7 +111,7 @@ void localSettingsOverrideClientDefaultSettings() throws Exception {
Configurable configurable = (Configurable) client;
given(configurable.getConfig()).willReturn(defaultConfig);

HttpComponentsClientHttpRequestFactory hrf = new HttpComponentsClientHttpRequestFactory(client);
HttpComponentsClientRequestFactory hrf = new HttpComponentsClientRequestFactory(client);
hrf.setConnectTimeout(5000);

RequestConfig requestConfig = retrieveRequestConfig(hrf);
Expand All @@ -130,7 +130,7 @@ void mergeBasedOnCurrentHttpClient() throws Exception {
Configurable configurable = (Configurable) client;
given(configurable.getConfig()).willReturn(defaultConfig);

HttpComponentsClientHttpRequestFactory hrf = new HttpComponentsClientHttpRequestFactory() {
HttpComponentsClientRequestFactory hrf = new HttpComponentsClientRequestFactory() {
@Override
public HttpClient getHttpClient() {
return client;
Expand Down Expand Up @@ -182,7 +182,7 @@ static Stream<HttpMethod> safeHttpMethods() {
return Stream.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.TRACE);
}

private RequestConfig retrieveRequestConfig(HttpComponentsClientHttpRequestFactory factory) throws Exception {
private RequestConfig retrieveRequestConfig(HttpComponentsClientRequestFactory factory) throws Exception {
URI uri = URI.create(baseUrl + "/status/ok");
HttpComponentsClientHttpRequest request = (HttpComponentsClientHttpRequest)
factory.createRequest(uri, HttpMethod.GET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactor

@Override
protected ClientHttpRequestFactory createRequestFactory() {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
HttpComponentsClientRequestFactory requestFactory = new HttpComponentsClientRequestFactory();
return new InterceptingClientHttpRequestFactory(requestFactory, null);
}

Expand Down
Loading

0 comments on commit 3d6e78b

Please sign in to comment.