Polish "Upgrade Spring Framework to 6.0.0 and Spring Boot to 3.0.0-RC2"
This commit is contained in:
@@ -139,9 +139,6 @@ subprojects {
|
||||
registerFeature('okhttp') {
|
||||
usingSourceSet(sourceSets.main)
|
||||
}
|
||||
registerFeature('netty') {
|
||||
usingSourceSet(sourceSets.main)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -45,8 +45,6 @@ dependencies {
|
||||
|
||||
okhttpImplementation("com.squareup.okhttp3:okhttp:${okHttp3Version}")
|
||||
|
||||
nettyImplementation("io.netty:netty-all:${nettyVersion}")
|
||||
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
|
||||
@@ -54,7 +54,6 @@ public final class ClientHttpConnectorFactory {
|
||||
|
||||
/**
|
||||
* Create a {@link ClientHttpConnector} for the given {@link ClientOptions}.
|
||||
*
|
||||
* @param options must not be {@literal null}
|
||||
* @return a new {@link ClientHttpConnector}.
|
||||
*/
|
||||
@@ -68,7 +67,7 @@ public final class ClientHttpConnectorFactory {
|
||||
httpClient = httpClient.secure((sslContextSpec) -> {
|
||||
try {
|
||||
sslContextSpec.sslContext(SslContextBuilder.forClient().sslProvider(SslProvider.JDK)
|
||||
.trustManager(trustManagerFactory).build());
|
||||
.trustManager(trustManagerFactory).build());
|
||||
}
|
||||
catch (SSLException ex) {
|
||||
logger.error("Error configuring HTTP connections using custom certs", ex);
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Factory for {@link ClientHttpRequestFactory} that supports Apache HTTP Components,
|
||||
* OkHttp, Netty and the JDK HTTP client (in that order). This factory configures a
|
||||
* OkHttp the JDK HTTP client (in that order). This factory configures a
|
||||
* {@link ClientHttpRequestFactory} depending on the available dependencies.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
@@ -57,7 +57,8 @@ public final class ClientHttpRequestFactoryFactory {
|
||||
|
||||
private static final SslCertificateUtils sslCertificateUtils = new SslCertificateUtils();
|
||||
|
||||
private static final boolean HTTP_COMPONENTS_PRESENT = ClassUtils.isPresent("org.apache.http.client.HttpClient",
|
||||
private static final boolean HTTP_COMPONENTS_PRESENT = ClassUtils.isPresent(
|
||||
"org.apache.hc.client5.http.impl.classic.HttpClients",
|
||||
ClientHttpRequestFactoryFactory.class.getClassLoader());
|
||||
|
||||
private static final boolean OKHTTP3_PRESENT = ClassUtils.isPresent("okhttp3.OkHttpClient",
|
||||
@@ -108,8 +109,7 @@ public final class ClientHttpRequestFactoryFactory {
|
||||
if (usingCustomCerts(options)) {
|
||||
logger.warn("Trust material will not be configured when using "
|
||||
+ "java.net.HttpUrlConnection. Use an alternate HTTP Client "
|
||||
+ "(Apache HttpComponents HttpClient or OkHttp3) when "
|
||||
+ "configuring CA certificates.");
|
||||
+ "(Apache HttpComponents HttpClient or OkHttp3) when configuring CA certificates.");
|
||||
}
|
||||
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
@@ -148,28 +148,23 @@ public final class ClientHttpRequestFactoryFactory {
|
||||
SSLContext sslContext = sslCertificateUtils.getSSLContext(options.getCaCertFiles());
|
||||
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext);
|
||||
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder
|
||||
.create()
|
||||
.setSSLSocketFactory(sslSocketFactory)
|
||||
.setDefaultSocketConfig(socketConfig)
|
||||
.build();
|
||||
.create().setSSLSocketFactory(sslSocketFactory).setDefaultSocketConfig(socketConfig).build();
|
||||
httpClientBuilder.setConnectionManager(connectionManager);
|
||||
}
|
||||
else {
|
||||
SSLContext sslContext = SSLContext.getDefault();
|
||||
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext);
|
||||
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder
|
||||
.create()
|
||||
.useSystemProperties()
|
||||
.setSSLSocketFactory(sslSocketFactory)
|
||||
.setDefaultSocketConfig(socketConfig)
|
||||
.build();
|
||||
.create().useSystemProperties().setSSLSocketFactory(sslSocketFactory)
|
||||
.setDefaultSocketConfig(socketConfig).build();
|
||||
httpClientBuilder.setConnectionManager(connectionManager);
|
||||
}
|
||||
|
||||
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom().setAuthenticationEnabled(true);
|
||||
|
||||
if (options.getConnectionTimeout() != null) {
|
||||
requestConfigBuilder.setConnectTimeout(Timeout.ofMilliseconds(options.getConnectionTimeout().toMillis()));
|
||||
requestConfigBuilder
|
||||
.setConnectTimeout(Timeout.ofMilliseconds(options.getConnectionTimeout().toMillis()));
|
||||
}
|
||||
httpClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
|
||||
|
||||
|
||||
@@ -112,9 +112,10 @@ public class ReactiveCredHubCertificateTemplate implements ReactiveCredHubCertif
|
||||
Map<String, Object> request = new HashMap<>(1);
|
||||
request.put(SIGNED_BY_REQUEST_FIELD, certificateName.getName());
|
||||
|
||||
return this.credHubOperations.doWithWebClient((webClient) -> webClient.post().uri(BULK_REGENERATE_URL_PATH)
|
||||
.bodyValue(request).retrieve().onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToFlux(ref)
|
||||
.flatMap((body) -> Flux.fromIterable(body.get(REGENERATED_CREDENTIALS_RESPONSE_FIELD))));
|
||||
return this.credHubOperations
|
||||
.doWithWebClient((webClient) -> webClient.post().uri(BULK_REGENERATE_URL_PATH).bodyValue(request)
|
||||
.retrieve().onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToFlux(ref)
|
||||
.flatMap((body) -> Flux.fromIterable(body.get(REGENERATED_CREDENTIALS_RESPONSE_FIELD))));
|
||||
}
|
||||
|
||||
public Flux<CertificateCredentialDetails> updateTransitionalVersion(final String id, final String versionId) {
|
||||
|
||||
@@ -78,9 +78,9 @@ public class ReactiveCredHubPermissionTemplate implements ReactiveCredHubPermiss
|
||||
Assert.notNull(name, "credential name must not be null");
|
||||
Assert.notNull(actor, "actor must not be null");
|
||||
|
||||
return this.credHubOperations.doWithWebClient(
|
||||
(webClient) -> webClient.delete().uri(PERMISSIONS_ACTOR_URL_QUERY, name.getName(), actor.getIdentity())
|
||||
.retrieve().onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToMono(Void.class));
|
||||
return this.credHubOperations.doWithWebClient((webClient) -> webClient.delete()
|
||||
.uri(PERMISSIONS_ACTOR_URL_QUERY, name.getName(), actor.getIdentity()).retrieve()
|
||||
.onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToMono(Void.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class ReactiveCredHubPermissionV2Template implements ReactiveCredHubPermi
|
||||
final CredentialPermission credentialPermission = new CredentialPermission(path, permission);
|
||||
|
||||
return this.credHubOperations.doWithWebClient((webClient) -> webClient.post().uri(PERMISSIONS_URL_PATH)
|
||||
.bodyValue(credentialPermission).retrieve().onStatus(HttpStatusCode::isError, ExceptionUtils::buildError)
|
||||
.bodyToMono(CredentialPermission.class));
|
||||
.bodyValue(credentialPermission).retrieve()
|
||||
.onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToMono(CredentialPermission.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,8 +92,8 @@ public class ReactiveCredHubPermissionV2Template implements ReactiveCredHubPermi
|
||||
final CredentialPermission credentialPermission = new CredentialPermission(path, permission);
|
||||
|
||||
return this.credHubOperations.doWithWebClient((webClient) -> webClient.put().uri(PERMISSIONS_ID_URL_PATH, id)
|
||||
.bodyValue(credentialPermission).retrieve().onStatus(HttpStatusCode::isError, ExceptionUtils::buildError)
|
||||
.bodyToMono(CredentialPermission.class));
|
||||
.bodyValue(credentialPermission).retrieve()
|
||||
.onStatus(HttpStatusCode::isError, ExceptionUtils::buildError).bodyToMono(CredentialPermission.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ Spring CredHub `CredHubOperations` supports multiple HTTP client libraries to co
|
||||
* Java’s builtin `HttpURLConnection` (default)
|
||||
* https://hc.apache.org/[Apache HttpComponents]
|
||||
* https://square.github.io/okhttp/[OkHttp 3]
|
||||
* https://netty.io/[Netty]
|
||||
|
||||
Choosing a specific client library requires the appropriate dependency to be available on the application classpath.
|
||||
The application classpath will be inspected for each client library in the order listed above.
|
||||
@@ -38,15 +37,3 @@ To use OkHttp 3 to communicate with CredHub, add the following dependency to the
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
=== Netty
|
||||
|
||||
To use Netty to communicate with CredHub, add the following dependency to the application:
|
||||
|
||||
[source,xml,%autofit]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
@@ -42,8 +42,6 @@ dependencies {
|
||||
|
||||
if (project.hasProperty("useOkHttp3")) {
|
||||
testImplementation("com.squareup.okhttp3:okhttp")
|
||||
} else if (project.hasProperty("useNetty")) {
|
||||
testImplementation("io.netty:netty-all")
|
||||
} else {
|
||||
testImplementation("org.apache.httpcomponents.client5:httpclient5:${httpClient5Version}")
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ dependencies {
|
||||
|
||||
okhttpImplementation("com.squareup.okhttp3:okhttp:${okHttp3Version}")
|
||||
|
||||
nettyImplementation("io.netty:netty-all:${nettyVersion}")
|
||||
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
Reference in New Issue
Block a user