feat: add Apache HttpClient 5.x adapter support#3614
Conversation
Add sentinel-apache-httpclient5-adapter module that integrates Sentinel flow control with Apache HttpClient 5.x outgoing HTTP requests. Features: - ExecChainHandler-based integration (SentinelApacheHttpClient5Handler) - Configurable resource name extraction (METHOD:URL format by default) - Query string and fragment stripping in resource names - Customizable fallback handling (throws SentinelRpcException by default) - Configurable resource name prefix (default: "httpclient:") Follows the same architecture pattern as the existing HttpClient 4.x adapter while adapting to HC5's ExecChainHandler API. Closes alibaba#3614 Change-Id: I966295da9419beac99451fc6c9c31b1d75a9e7e6 Co-developed-by: Cursor <noreply@cursor.com>
After the 1.8.9 release, several PRs have been merged but the development version was not updated. Bump to 1.8.10-SNAPSHOT for next development iteration. Change-Id: I2b7ba2b5b4e9e39d1f9749288d54b9926a512132 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I1fe4682e41185dc7c8ed30541989f2881ba87549 Co-developed-by: Cursor <noreply@cursor.com>
CI Failure AnalysisThe CI build failure is not related to this PR. The failing test is: This is a pre-existing flaky test in For reference, the upstream All 21 tests in the |
Change-Id: Ie28f99434badfc00decc914ffd27f83c837d947d Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I60caec5b17e92a79827671e531a0818f61163b48 Co-developed-by: Cursor <noreply@cursor.com>
LearningGp
left a comment
There was a problem hiding this comment.
The default extractor in HC4 returns only the URI path (e.g., /api/users), while HC5 returns METHOD:FULL_URL (e.g., GET:http://host/api/users). This results in incompatible resource naming conventions under the httpclient: prefix across the two versions. For users upgrading from HC4 to HC5, all existing flow control rules will break. I suggest clearly documenting this discrepancy and including migration notes in the README.
Document the default resource name format difference between HC4 and HC5 adapters so users understand that existing flow control rules will not match automatically after migration, and provide a snippet for preserving the legacy URI-only naming via a custom extractor. Change-Id: Iadacf3d3288acb4b23ce67441a88c0b8ad0f0b6e Co-developed-by: Claude <noreply@anthropic.com>
What does this PR do?
Add
sentinel-apache-httpclient5-adaptermodule that integrates Sentinel flow control with Apache HttpClient 5.x outgoing HTTP requests.This is a companion to the existing
sentinel-apache-httpclient-adapter(4.x), providing the same Sentinel protection capabilities for users who have migrated to HttpClient 5.x.Features
SentinelApacheHttpClient5Handlerimplements HC5'sExecChainHandlerinterface, allowing seamless integration viaHttpClients.custom().addExecInterceptorBefore()METHOD:URLformat resource names (e.g.,GET:http://example.com/api/users), with query string and fragment strippingSentinelRpcException; users can implement customApacheHttpClientFallbackfor alternative responseshttpclient:, fully customizableUsage
Architecture
Follows the same design pattern as the existing HttpClient 4.x adapter:
SentinelApacheHttpClient5Handler— core handler (ExecChainHandler)SentinelApacheHttpClientConfig— configuration holderApacheHttpClientResourceExtractor/DefaultApacheHttpClientResourceExtractor— resource name extractionApacheHttpClientFallback/DefaultApacheHttpClientFallback— fallback handlingTest Coverage
Closes #3614
Made with Cursor