-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support custom retryable exceptions via @RetryableException #1507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Support custom retryable exceptions via @RetryableException #1507
Conversation
WalkthroughIntroduces a provider-side annotation to mark exceptions as retryable, maps such exceptions to a new CUSTOMER_RETRY_ERROR type, and adds client-side logic to retry invocations when this error is returned. No public API signatures changed beyond adding the new annotation and error constant. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor C as Client
participant FC as FailoverCluster
participant P as ProviderInvoker
participant S as Service Impl
rect rgb(245,248,255)
C->>FC: invoke(request)
loop per attempt until max
FC->>P: invoke(request)
P->>S: method call
alt Service throws @RetryableException cause
S-->>P: throws InvocationTargetException(cause)
P-->>FC: SofaRpcException(type=CUSTOMER_RETRY_ERROR)
note over FC: Detects CUSTOMER_RETRY_ERROR<br/>increments retry count
FC-->>P: retry with next provider
else Non-retryable exception or success
S-->>P: return or non-retryable error
P-->>FC: response/appResponse
FC-->>C: return
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes(no out-of-scope functional changes detected) Suggested reviewers
Poem
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java (1)
111-114
: Rename constant and add a dedicated 300-range section header.“CUSTOMER” reads as end-user; here it’s “custom.” Also keep sectioning consistent with 100–199/200–299 blocks.
Apply:
- /** - * 用户自定义可重试异常 - */ - public static final int CUSTOMER_RETRY_ERROR = 300; + // ==== 应用/业务可重试异常码 300-399 ====== + /** + * 用户自定义可重试异常 + */ + public static final int CUSTOM_RETRY_ERROR = 300;core-impl/client/src/main/java/com/alipay/sofa/rpc/client/FailoverCluster.java (1)
70-78
: Use the renamed error constant; logic otherwise looks good.Keeps retries bounded and preserves existing logging behavior.
Apply:
- if (appResponse instanceof SofaRpcException) { - if (((SofaRpcException) appResponse).getErrorType() == RpcErrorType.CUSTOMER_RETRY_ERROR) { + if (appResponse instanceof SofaRpcException) { + if (((SofaRpcException) appResponse).getErrorType() == RpcErrorType.CUSTOM_RETRY_ERROR) { time++; throwable = (SofaRpcException) appResponse; continue; } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
core-impl/client/src/main/java/com/alipay/sofa/rpc/client/FailoverCluster.java
(1 hunks)core/api/src/main/java/com/alipay/sofa/rpc/filter/ProviderInvoker.java
(2 hunks)core/common/src/main/java/com/alipay/sofa/rpc/common/annotation/RetryableException.java
(1 hunks)core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: build
core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java
[error] 1-1: Uncommitted changes detected. Please commit core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java before continuing.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: sca
🔇 Additional comments (1)
core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java (1)
111-114
: Fix CI: commit this file.CI reports “Uncommitted changes detected” for this path. Ensure the modified file is added and committed to the PR.
Support custom retryable exceptions via @RetryableException.
Fixes #1362
Summary by CodeRabbit