Skip to content

Commit

Permalink
Merge pull request #773 from commercetools/upgrade_httpasyncclient
Browse files Browse the repository at this point in the history
Update Apache AsyncHttpClient
  • Loading branch information
jenschude authored Dec 19, 2024
2 parents 54fba54 + 1d8f3f6 commit d157f9a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 41 deletions.
6 changes: 3 additions & 3 deletions commercetools/commercetools-apachehttp-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

dependencies {
api project(":rmf:rmf-java-base")
api "org.apache.httpcomponents.client5:httpclient5:5.3.1" version {
strictly "[5.0,6.0["
prefer "5.1.3"
api "org.apache.httpcomponents.client5:httpclient5:5.4.1" version {
strictly "[5.4.1,6.0["
prefer "5.4.1"
}

api commons.io version commons.io_version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

package com.commercetools.http.apachehttp;

import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.core5.util.VersionInfo;

public class ApacheHttpClientSolutionInfo extends io.vrap.rmf.base.client.SolutionInfo {
public ApacheHttpClientSolutionInfo() {
setName("ApacheHttpAsyncClient");
setVersion(
VersionInfo.loadVersionInfo("org.apache.hc.client5", HttpClient.class.getClassLoader()).getRelease());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.hc.client5.http.async.methods.SimpleBody;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
import org.apache.hc.client5.http.config.TlsConfig;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
Expand All @@ -32,7 +33,6 @@
import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.reactor.IOReactorStatus;
import org.apache.hc.core5.reactor.ssl.TlsDetails;

public class CtApacheHttpClient extends HttpClientBase {
public static final int MAX_REQUESTS = 64;
Expand All @@ -46,19 +46,19 @@ public static HttpAsyncClientBuilder createClientBuilder() {
}

public static HttpAsyncClientBuilder createClientBuilder(AsyncClientConnectionManager cm) {
return HttpAsyncClientBuilder.create().setVersionPolicy(HttpVersionPolicy.NEGOTIATE).setConnectionManager(cm);
return HttpAsyncClientBuilder.create().setConnectionManager(cm);
}

public static PoolingAsyncClientConnectionManagerBuilder createConnectionManager(final int maxConnTotal,
final int maxConnPerRoute) {
final TlsStrategy tlsStrategy = ClientTlsStrategyBuilder.create()
.useSystemProperties()
.setTlsDetailsFactory(
sslEngine -> new TlsDetails(sslEngine.getSession(), sslEngine.getApplicationProtocol()))
final TlsStrategy tlsStrategy = ClientTlsStrategyBuilder.create().useSystemProperties().build();
final TlsConfig tlsConfig = TlsConfig.copy(TlsConfig.DEFAULT)
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.build();
return PoolingAsyncClientConnectionManagerBuilder.create()
.setMaxConnPerRoute(maxConnPerRoute)
.setMaxConnTotal(maxConnTotal)
.setDefaultTlsConfig(tlsConfig)
.setTlsStrategy(tlsStrategy);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.commercetools.http.apachehttp.ApacheHttpClientSolutionInfo
19 changes: 3 additions & 16 deletions licenses/commercetools-apachehttp-client/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@
}
]
},
{
"moduleName": "commons-codec:commons-codec",
"moduleVersion": "1.15",
"moduleUrls": [
"https://commons.apache.org/proper/commons-codec/"
],
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
"moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0"
}
]
},
{
"moduleName": "commons-io:commons-io",
"moduleVersion": "2.11.0",
Expand Down Expand Up @@ -155,7 +142,7 @@
},
{
"moduleName": "org.apache.httpcomponents.client5:httpclient5",
"moduleVersion": "5.1.3",
"moduleVersion": "5.4.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand All @@ -165,7 +152,7 @@
},
{
"moduleName": "org.apache.httpcomponents.core5:httpcore5",
"moduleVersion": "5.1.3",
"moduleVersion": "5.3.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand All @@ -175,7 +162,7 @@
},
{
"moduleName": "org.apache.httpcomponents.core5:httpcore5-h2",
"moduleVersion": "5.1.3",
"moduleVersion": "5.3.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand Down
19 changes: 3 additions & 16 deletions licenses/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,6 @@
}
]
},
{
"moduleName": "commons-codec:commons-codec",
"moduleVersion": "1.15",
"moduleUrls": [
"https://commons.apache.org/proper/commons-codec/"
],
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
"moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0"
}
]
},
{
"moduleName": "commons-io:commons-io",
"moduleVersion": "2.11.0",
Expand Down Expand Up @@ -1220,7 +1207,7 @@
},
{
"moduleName": "org.apache.httpcomponents.client5:httpclient5",
"moduleVersion": "5.1.3",
"moduleVersion": "5.4.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand All @@ -1230,7 +1217,7 @@
},
{
"moduleName": "org.apache.httpcomponents.core5:httpcore5",
"moduleVersion": "5.1.3",
"moduleVersion": "5.3.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand All @@ -1240,7 +1227,7 @@
},
{
"moduleName": "org.apache.httpcomponents.core5:httpcore5-h2",
"moduleVersion": "5.1.3",
"moduleVersion": "5.3.1",
"moduleLicenses": [
{
"moduleLicense": "Apache License, Version 2.0",
Expand Down

0 comments on commit d157f9a

Please sign in to comment.