From 800730f413b589764e3f1f802f160644bb345bcf Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 17 Oct 2022 15:36:25 +0200 Subject: [PATCH] Polishing. Update RequestConfig. Upgrade to newer Vault version. Closes gh-727, closes gh-728 --- pom.xml | 66 ++++++++++++++----- .../ClientHttpRequestFactoryFactory.java | 16 ++--- src/test/bash/install_vault.sh | 4 +- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 147718cc..e861adee 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 org.springframework.vault @@ -27,10 +29,10 @@ 1.6.2 1.12.4 4.6.1 - 6.0.0-SNAPSHOT - 2022.0.0-M5 + 6.0.0-RC1 + 2022.0.0-RC1 6.0.0-M6 - 2022.0.0-M4 + 2022.0.0-RC1 17 multi spring-vault @@ -39,7 +41,7 @@ ${project.build.directory}/doc-resources - + 2016 @@ -319,6 +321,26 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-java-version + + enforce + + + + + 17 + + + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -437,6 +459,12 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.1.0 + + org.apache.maven.plugins maven-surefire-plugin @@ -492,7 +520,8 @@ https://projectreactor.io/docs/core/release/api/ - https://docs.oracle.com/en/java/javase/17/docs/api/ + https://docs.oracle.com/en/java/javase/17/docs/api/ + @@ -671,7 +700,6 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 enforce-no-third-party-snapshots @@ -680,8 +708,9 @@ - - + + true @@ -741,7 +770,8 @@ sonatype-nexus-snapshots Sonatype Nexus Snapshots - https://s01.oss.sonatype.org/content/repositories/snapshots/ + https://s01.oss.sonatype.org/content/repositories/snapshots/ + sonatype-nexus-staging @@ -854,15 +884,21 @@ false - {{artifactory.server}} + {{artifactory.server}} + {{artifactory.username}} {{artifactory.password}} - {{artifactory.staging-repository}} - {{artifactory.staging-repository}} + {{artifactory.staging-repository}} + + + {{artifactory.staging-repository}} + - {{artifactory.build-name}} - {{artifactory.build-number}} + {{artifactory.build-name}} + + {{artifactory.build-number}} + {{BUILD_URL}} diff --git a/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java b/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java index d96ad17a..75582aed 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java @@ -57,6 +57,7 @@ import org.apache.hc.client5.http.impl.routing.SystemDefaultRoutePlanner; import org.apache.hc.client5.http.ssl.HttpsSupport; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; import org.apache.hc.core5.http.io.SocketConfig; +import org.apache.hc.core5.util.Timeout; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; @@ -80,6 +81,7 @@ import org.springframework.vault.support.SslConfiguration.KeyStoreConfiguration; * * @author Mark Paluch * @author Ryan Gow + * @author Spencer Gibb * @since 2.2 */ public class ClientHttpRequestFactoryFactory { @@ -310,26 +312,18 @@ public class ClientHttpRequestFactoryFactory { PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder // .create().setSSLSocketFactory(sslSocketFactory) // .setDefaultSocketConfig(SocketConfig.custom() // - .setSoTimeout(Math.toIntExact(options.getReadTimeout().toMillis()), - TimeUnit.MILLISECONDS) - .build()) // + .setSoTimeout(Timeout.ofMilliseconds(options.getReadTimeout().toMillis())).build()) // .build(); // httpClientBuilder.setConnectionManager(connectionManager); } RequestConfig requestConfig = RequestConfig.custom() - // - .setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis()), - TimeUnit.MILLISECONDS) // + .setConnectTimeout(Timeout.ofMilliseconds(options.getConnectionTimeout().toMillis())) .setAuthenticationEnabled(true) // - .build(); + .setRedirectsEnabled(true).build(); httpClientBuilder.setDefaultRequestConfig(requestConfig); - // Support redirects - // TODO: DefaultRedirectStrategy doesn't take method into account - // httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy()); - return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build()); } diff --git a/src/test/bash/install_vault.sh b/src/test/bash/install_vault.sh index 1437ff49..3a42a126 100755 --- a/src/test/bash/install_vault.sh +++ b/src/test/bash/install_vault.sh @@ -8,8 +8,8 @@ set -o errexit EDITION="${EDITION:-oss}" -VAULT_OSS="${VAULT_OSS:-1.8.1}" -VAULT_ENT="${VAULT_ENT:-1.8.1}" +VAULT_OSS="${VAULT_OSS:-1.11.0}" +VAULT_ENT="${VAULT_ENT:-1.11.0}" UNAME=$(uname -s | tr '[:upper:]' '[:lower:]') VERBOSE=false VAULT_DIRECTORY=vault