Skip to content

Updates to apache client5 #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<kotlin-coroutines.version>1.6.2</kotlin-coroutines.version>
<mockk.version>1.12.4</mockk.version>
<mockito-core.version>4.6.1</mockito-core.version>
<spring.version>6.0.0-M5</spring.version>
<spring.version>6.0.0-SNAPSHOT</spring.version>
<spring-data-bom.version>2022.0.0-M5</spring-data-bom.version>
<spring-security-bom.version>6.0.0-M6</spring-security-bom.version>
<reactor.version>2022.0.0-M4</reactor.version>
Expand Down
8 changes: 4 additions & 4 deletions spring-vault-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@
<!-- HTTP clients -->

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
<optional>true</optional>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
import okhttp3.OkHttpClient.Builder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.impl.conn.DefaultSchemePortResolver;
import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
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.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
Expand Down Expand Up @@ -303,22 +306,29 @@ static ClientHttpRequestFactory usingHttpComponents(ClientOptions options, SslCo
}

SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext,
enabledProtocols, enabledCipherSuites, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
httpClientBuilder.setSSLContext(sslContext);
enabledProtocols, enabledCipherSuites, HttpsSupport.getDefaultHostnameVerifier());
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder //
.create().setSSLSocketFactory(sslSocketFactory) //
.setDefaultSocketConfig(SocketConfig.custom() //
.setSoTimeout(Math.toIntExact(options.getReadTimeout().toMillis()),
TimeUnit.MILLISECONDS)
.build()) //
.build(); //
httpClientBuilder.setConnectionManager(connectionManager);
}

RequestConfig requestConfig = RequestConfig.custom()
//
.setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis())) //
.setSocketTimeout(Math.toIntExact(options.getReadTimeout().toMillis())) //
.setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis()),
TimeUnit.MILLISECONDS) //
.setAuthenticationEnabled(true) //
.build();

httpClientBuilder.setDefaultRequestConfig(requestConfig);

// Support redirects
httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
// TODO: DefaultRedirectStrategy doesn't take method into account
// httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing comparable in client5


return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
}
Expand Down
12 changes: 6 additions & 6 deletions spring-vault-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
</licenses>

<properties>
<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.15</httpcore.version>
<httpclient.version>5.1.3</httpclient.version>
<httpcore.version>5.1.4</httpcore.version>
<jetty-reactive-httpclient.version>3.0.6</jetty-reactive-httpclient.version>
<netty.version>4.1.79.Final</netty.version>
<okhttp3.version>3.14.9</okhttp3.version>
Expand Down Expand Up @@ -89,8 +89,8 @@

<!-- HTTP Client Libraries -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient.version}</version>
<optional>true</optional>
<exclusions>
Expand All @@ -102,8 +102,8 @@
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
<version>${httpcore.version}</version>
<optional>true</optional>
</dependency>
Expand Down
7 changes: 5 additions & 2 deletions src/test/bash/install_vault.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
set -o errexit

EDITION="${EDITION:-oss}"
VAULT_OSS="${VAULT_OSS:-1.6.1}"
VAULT_ENT="${VAULT_ENT:-1.6.1}"
VAULT_OSS="${VAULT_OSS:-1.8.1}"
VAULT_ENT="${VAULT_ENT:-1.8.1}"
UNAME=$(uname -s | tr '[:upper:]' '[:lower:]')
VERBOSE=false
VAULT_DIRECTORY=vault
Expand Down Expand Up @@ -147,6 +147,9 @@ function main() {

initialize
parse_options "$@"
if [ "$(uname -m)" == arm64 ]; then
PLATFORM=arm64
fi
if [ "$(uname -m)" == aarch64 ]; then
PLATFORM=arm64
fi
Expand Down