Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,17 @@ public PoolingHttpClientConnectionManager create(Apache5HttpClient.DefaultBuilde
// TODO : Deprecated method needs to be removed with new replacements
SSLConnectionSocketFactory sslsf = getPreferredSocketFactory(configuration, standardOptions);

PoolingHttpClientConnectionManager cm =
PoolingHttpClientConnectionManagerBuilder builder =
PoolingHttpClientConnectionManagerBuilder.create()
.setSSLSocketFactory(sslsf)
.setSchemePortResolver(DefaultSchemePortResolver.INSTANCE)
.setDnsResolver(configuration.dnsResolver)
.setConnectionTimeToLive(
TimeValue.of(standardOptions.get(
SdkHttpConfigurationOption.CONNECTION_TIME_TO_LIVE).toMillis(),
TimeUnit.MILLISECONDS))
.build();
.setDnsResolver(configuration.dnsResolver);
Duration connectionTtl = standardOptions.get(SdkHttpConfigurationOption.CONNECTION_TIME_TO_LIVE);
if (!connectionTtl.isZero()) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that SdkHttpConfigurationOption sets default value as 0 in

private static final Duration DEFAULT_CONNECTION_TIME_TO_LIVE = Duration.ZERO;

// Skip TTL=0 to maintain backward compatibility (infinite in 4.x vs immediate expiration in 5.x)
builder.setConnectionTimeToLive(TimeValue.of(connectionTtl.toMillis(), TimeUnit.MILLISECONDS));
}
PoolingHttpClientConnectionManager cm = builder.build();


cm.setDefaultMaxPerRoute(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ public void credentialPlannerIsInvoked() throws Exception {
mockProxyServer.verify(2, RequestPatternBuilder.allRequests());
}


@Override
public void connectionPoolingWorks() throws Exception {
// TODO : future PR will handle this.
}

Comment on lines -157 to -161
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Junit added back with this PR , earlier it was commented.

Is that this test? Its being removed not added back

Copy link
Copy Markdown
Contributor Author

@joviegas joviegas Jun 10, 2025

Choose a reason for hiding this comment

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

Since Apache5HttpClientWireMockTest extends SdkHttpClientTestSuite

Its been added back , since we removed the empty test from here it will pick up the actual test from

public void connectionPoolingWorks() throws Exception {
int initialOpenedConnections = CONNECTION_COUNTER.openedConnections();
SdkHttpClientOptions httpClientOptions = new SdkHttpClientOptions();
httpClientOptions.trustAll(true);
try (SdkHttpClient client = createSdkHttpClient(httpClientOptions)) {
stubForMockRequest(200);
for (int i = 0; i < 5; i++) {
SdkHttpFullRequest req = mockSdkRequest("http://localhost:" + mockServer.port(), SdkHttpMethod.POST);
HttpExecuteResponse response =
client.prepareRequest(HttpExecuteRequest.builder()
.request(req)
.contentStreamProvider(req.contentStreamProvider().orElse(null))
.build())
.call();
response.responseBody().ifPresent(IoUtils::drainInputStream);
}
// connection pool growth strategies vary across client implementations. Some, such as the CRT grow connection counts
// by a factor of 2, while some grow strictly as requested. Mainly we want to test that it kicks in at some point and
// doesn't create a new connection for all 5 requests. This proves that while allowing variance in this behavior.
assertThat(CONNECTION_COUNTER.openedConnections()).isGreaterThanOrEqualTo(initialOpenedConnections + 1);
assertThat(CONNECTION_COUNTER.openedConnections()).isLessThanOrEqualTo(initialOpenedConnections + 2);
}
}

@Test
public void overrideDnsResolver_WithDnsMatchingResolver_successful() throws Exception {
overrideDnsResolver("magic.local.host");
Expand Down
Loading