Move connection timeout configuration from RequestConfig to ConnectionConfig in Apache HttpClient 5 #6293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This change addresses the use of deprecated APIs in Apache HttpClient 5. The
setConnectTimeout()
method inRequestConfig.Builder
is deprecated and should be replaced with proper connection-level timeout configuration viaConnectionConfig
.In Apache HttpClient 5, the architecture separates:
ConnectionConfig
RequestConfig
This change aligns our implementation with Apache HttpClient 5's recommended practices and eliminates deprecated API usage warnings.
Modifications
connectionTimeout
fromApache5HttpRequestConfig
- This timeout is now managed at the connection manager levelgetConnectionConfig()
method inApacheConnectionManagerFactory
to centralize connection-level timeout configurationConnectionConfig
instead ofRequestConfig
addRequestConfig()
method inApache5HttpRequestFactory
to remove deprecatedsetConnectTimeout()
callTesting
connectionTimeout_exceedsLimit_throwsException()
test - Validates connection timeout using non-routable IP address (192.0.2.1) with 100ms timeoutsocketTimeout_exceedsLimit_throwsException()
test - Validates socket timeout using WireMock with 2-second delay and 500ms timeoutMetricReportingTest
andApacheHttpRequestFactoryTest
The tests confirm that:
Screenshots (if appropriate)