-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support custom retryable exceptions via @RetryableException (#1362) #1491
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?
Conversation
Hi @wunameya, welcome to SOFAStack community, Please sign Contributor License Agreement! After you signed CLA, we will automatically sync the status of this pull request in 3 minutes. |
""" WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant FailoverCluster
participant Provider
Client->>FailoverCluster: invoke(request)
loop Retry Loop
FailoverCluster->>Provider: sendRequest(request)
Provider-->>FailoverCluster: SofaResponse
alt Response is Throwable with @RetryableException
FailoverCluster->>FailoverCluster: Mark as retryable, increment retry count
FailoverCluster->>Provider: Retry sendRequest(request)
else Response is OK or non-retryable error
FailoverCluster-->>Client: return response
end
end
Assessment against linked issues
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
🧹 Nitpick comments (1)
core-impl/client/src/main/java/com/alipay/sofa/rpc/client/FailoverCluster.java (1)
71-93
: Correct implementation of custom retryable exception handling.The implementation properly checks for custom retryable exceptions and integrates well with the existing retry mechanism. The code correctly traverses the entire exception cause chain to find any exception annotated with @RetryableException.
Minor optimization: Consider breaking out of the cause chain traversal early once a retryable exception is found:
while (cause != null) { if (cause.getClass().isAnnotationPresent(RetryableException.class)) { retryable = true; break; } cause = cause.getCause(); }Also, consider translating the Chinese comment on line 71 to English for consistency:
- // 检查是否是用户自定义的可重试异常 + // Check for user-defined retryable exceptions
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (2)
core-impl/client/src/main/java/com/alipay/sofa/rpc/client/FailoverCluster.java
(2 hunks)core/common/src/main/java/com/alipay/sofa/rpc/common/annotation/RetryableException.java
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: sca
🔇 Additional comments (2)
core/common/src/main/java/com/alipay/sofa/rpc/common/annotation/RetryableException.java (1)
21-25
: Well-designed annotation for marking retryable exceptions.The implementation follows Java annotation best practices with appropriate metadata:
@Documented
ensures the annotation appears in Javadoc@Target(ElementType.TYPE)
correctly restricts usage to classes/interfaces@Retention(RetentionPolicy.RUNTIME)
makes it available at runtime for reflectionThis is a clean, minimal marker annotation that serves its purpose well.
core-impl/client/src/main/java/com/alipay/sofa/rpc/client/FailoverCluster.java (1)
21-21
: LGTM - Good import addition for the new annotation.The import statement is properly added to reference the new RetryableException annotation.
Support custom retryable exceptions via @RetryableException.
Fixes #1362
Summary by CodeRabbit