Open
Conversation
Change-Id: I49c8b1cf7a0a6f357b68b58bd352efc5981b76b2 Co-developed-by: OpenCode <noreply@opencode.ai>
Change-Id: Ieacaf949222f5871f934d2f0aa3bd6d73d1a087b
Change-Id: I2df54be42732b1c1786b4b9189639913b4598fd9 Co-developed-by: OpenCode <noreply@opencode.ai>
Change-Id: Ia9dceb36c2ef3a9a86a61110446c6aec4de331a9 Co-developed-by: OpenCode <noreply@opencode.ai>
Change-Id: I10f1752fa921aa8980e640c4fe7726d3c1764f37 Co-developed-by: OpenCode <noreply@opencode.ai>
LearningGp
requested changes
Mar 12, 2026
...n/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptor.java
Show resolved
Hide resolved
...n/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptor.java
Outdated
Show resolved
Hide resolved
...a/com/alibaba/csp/sentinel/adapter/spring/restclient/fallback/DefaultRestClientFallback.java
Outdated
Show resolved
Hide resolved
...main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelClientHttpResponse.java
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Sentinel adapter module to integrate with Spring Framework 6+ RestClient, providing resource extraction, flow-control/circuit-breaking interception, and fallback handling.
Changes:
- Introduces
SentinelRestClientInterceptorwith configurable resource naming and fallback behavior. - Adds default implementations for resource extraction and blocked-request fallback response.
- Adds a new Maven module with documentation and a set of unit/integration-style tests.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| sentinel-adapter/pom.xml | Registers the new sentinel-spring-restclient-adapter module in the parent build. |
| sentinel-adapter/sentinel-spring-restclient-adapter/pom.xml | Adds module dependencies (Spring Web/Boot/Test) and Surefire configuration. |
| sentinel-adapter/sentinel-spring-restclient-adapter/README.md | Documents adapter usage, configuration, and resource naming. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptor.java | Implements the RestClient request interceptor with dual-level resource entries and fallback handling. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientConfig.java | Provides configuration (prefix, extractor, fallback) for the interceptor. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelClientHttpResponse.java | Defines the default blocked-response ClientHttpResponse implementation. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/extractor/RestClientResourceExtractor.java | Introduces extractor SPI for resource naming. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/extractor/DefaultRestClientResourceExtractor.java | Implements default resource naming from method + URL components. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/fallback/RestClientFallback.java | Introduces fallback SPI for blocked requests. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/fallback/DefaultRestClientFallback.java | Provides default blocked-request fallback response. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptorSimpleTest.java | Adds integration-style tests around flow control/degrade with an embedded Spring Boot app. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/ManualTest.java | Adds a manual runnable test/demo for the adapter. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientConfigTest.java | Adds config validation tests (null extractor/fallback). |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelClientHttpResponseTest.java | Adds tests for blocked-response behavior. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/extractor/DefaultRestClientResourceExtractorTest.java | Adds tests for default resource name formatting. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/fallback/DefaultRestClientFallbackTest.java | Adds tests for default fallback handling. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/app/TestApplication.java | Provides Spring Boot test application used by integration tests. |
| sentinel-adapter/sentinel-spring-restclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/app/TestController.java | Provides endpoints used by integration tests (hello/users/error/delay). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ain/java/com/alibaba/csp/sentinel/adapter/spring/restclient/fallback/RestClientFallback.java
Show resolved
Hide resolved
...m/alibaba/csp/sentinel/adapter/spring/restclient/fallback/DefaultRestClientFallbackTest.java
Outdated
Show resolved
Hide resolved
...n/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptor.java
Outdated
Show resolved
Hide resolved
...main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelClientHttpResponse.java
Show resolved
Hide resolved
...main/java/com/alibaba/csp/sentinel/adapter/spring/restclient/SentinelClientHttpResponse.java
Show resolved
Hide resolved
Comment on lines
+40
to
+43
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import java.util.concurrent.atomic.AtomicReference; |
There was a problem hiding this comment.
These imports (CountDownLatch, TimeUnit, AtomicBoolean, AtomicReference) are not used in the test class as shown. Please remove unused imports to avoid warnings and keep the test file focused.
Suggested change
| import java.util.concurrent.CountDownLatch; | |
| import java.util.concurrent.TimeUnit; | |
| import java.util.concurrent.atomic.AtomicBoolean; | |
| import java.util.concurrent.atomic.AtomicReference; |
.../alibaba/csp/sentinel/adapter/spring/restclient/SentinelRestClientInterceptorSimpleTest.java
Show resolved
Hide resolved
...ent-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/spring/restclient/ManualTest.java
Show resolved
Hide resolved
- DefaultRestClientFallback now throws SentinelRpcException for consistency with other client adapters (okhttp, apache-httpclient) - SentinelClientHttpResponse uses text/plain instead of application/json since the body is plain text - Update tests to reflect new exception-throwing behavior Change-Id: I778bb9bba1bd24435e667f996ebbff19d734b14a Co-developed-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe what this PR does / why we need it
Closes #3601
Does this pull request fix one issue?
Closes #3601
Describe how you did it
add Sentinel RestClient Interceptor
Describe how to verify it
Run com.alibaba.csp.sentinel.adapter.spring.restclient.SentinelRestClientInterceptorSimpleTest to confirm the flow control behavior of Sentinel.
Special notes for reviews
None