-
Notifications
You must be signed in to change notification settings - Fork 852
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
Fix: serialize exception response #335
Conversation
@JoeCqupt Great! I will appreciate if you could add a unit test for it. |
WalkthroughThe recent changes involve enhancing the error handling and logging mechanisms within an RPC framework. Specifically, adjustments were made to re-serialize responses in the event of exceptions and to rigorously test the serialization of Throwable responses. This ensures more robust error reporting and handling, improving the framework's reliability and debugging capabilities. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (2)
- src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java (1 hunks)
- src/test/java/com/alipay/remoting/rpc/serializer/ClassCustomSerializerTest.java (3 hunks)
Additional Context Used
Additional comments not posted (3)
src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java (1)
182-187
: The changes to re-serialize the response in case of an exception and log an error if this fails are sensible. It ensures robust error handling by guaranteeing that even error responses are properly serialized before being sent. However, it would be beneficial to add a comment explaining the rationale behind re-serializing the response for future maintainers.src/test/java/com/alipay/remoting/rpc/serializer/ClassCustomSerializerTest.java (2)
23-28
: The added imports forAtomicBoolean
,DefaultCustomSerializer
,ResponseCommand
,InvokeServerException
, andRpcServerException
are necessary for the new test method and are correctly placed. Good job ensuring that only the required imports are added.
309-346
: ThetestResponseSerialThrowable
method is well-implemented, effectively testing the serialization of a response when aThrowable
is thrown. The use ofAtomicBoolean
to track serialization attempts is appropriate. To improve maintainability, consider adding comments explaining the purpose of the test and the significance of each assertion. This will make it easier for future maintainers to understand the test's intent and logic.
done |
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.
lgtm
* serialize exception response * add unit test
Why make this change?
https://github.com/sofastack/sofa-bolt/blob/master/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java#L180
response forgot to serialize
Summary by CodeRabbit
Throwable
during response serialization, ensuring robust error management.