-
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
WalkthroughAdds a provider-side marker annotation and an error code, maps annotated exceptions to a new CUSTOMER_RETRY_ERROR on provider, and implements client-side retry when the response's app exception indicates CUSTOMER_RETRY_ERROR. No public method signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant FailoverCluster
participant ProviderInvoker
participant ServiceImpl
Client->>FailoverCluster: invoke(request)
loop attempts (until max)
FailoverCluster->>ProviderInvoker: invoke(request)
ProviderInvoker->>ServiceImpl: call method
alt Service throws annotated exception
ServiceImpl-->>ProviderInvoker: InvocationTargetException(cause@RetryableException)
ProviderInvoker-->>FailoverCluster: response with appResponse = SofaRpcException(CUSTOMER_RETRY_ERROR)
FailoverCluster->>FailoverCluster: detect CUSTOMER_RETRY_ERROR, increment retry count
FailoverCluster-->>ProviderInvoker: try next provider (loop)
else Success or non-retryable error
ServiceImpl-->>ProviderInvoker: return / non-retryable error
ProviderInvoker-->>FailoverCluster: response/appResponse
FailoverCluster-->>Client: return final response
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)core/api/src/main/java/com/alipay/sofa/rpc/filter/ProviderInvoker.java (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). (2)
🔇 Additional comments (1)
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
✏️ Tip: You can customize this high-level summary in your review settings.