-
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: sendResponse if RpcRequestProcessor.doProcess throw Throwable #334
Conversation
PTAL @OrezzerO @nobodyiam |
I try to explore why . maybe this comment show the reason : but
|
I agree a clear response is necessary way of handling exceptions. @chuailiwu would you please help to take a look? |
src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java
Outdated
Show resolved
Hide resolved
Do agree that a clear response is necessary. As the comment said |
WalkthroughThe recent update focuses on refining the error logging mechanism within the RpcRequestProcessor's 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: 2
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/exception/ExceptionTest.java (1 hunks)
Additional Context Used
Additional comments not posted (1)
src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java (1)
398-402
: The error handling and response sending logic in theProcessTask
'srun
method has been updated to ensure that a response is sent back in case of exceptions. This change aligns with the PR objectives and improves the robustness of the error handling mechanism. However, consider adding more context to the error message, such as the type of exception caught, to aid in debugging.
|
||
RequestBody req = new RequestBody(4, "hello world"); | ||
try { | ||
client.invokeSync(addr, req, 3000); |
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.
To ensure the test fails if client.invokeSync
does not throw an exception, add Assert.fail();
after this line. This change makes the test's intention clearer and ensures it properly fails when the expected exception is not thrown.
+ Assert.fail("Expected InvokeServerException was not thrown.");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
client.invokeSync(addr, req, 3000); | |
client.invokeSync(addr, req, 3000); | |
Assert.fail("Expected InvokeServerException was not thrown."); |
logger.error(errMsg); | ||
Assert.fail(errMsg); | ||
} catch (InvokeServerException e) { | ||
Assert.assertTrue(true); |
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.
The assertion Assert.assertTrue(true);
is redundant and does not contribute to the test's effectiveness. Consider removing it or replacing it with a more meaningful assertion, such as checking the message or type of the caught exception if applicable.
- Assert.assertTrue(true);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
Assert.assertTrue(true); |
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.
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
…ofastack#334) * fix: sendResponse if RpcRequestProcessor.doProcess throw Throwable in ProcessTask * update unit test * update unit test
Fix: sendResponse if RpcRequestProcessor.doProcess throw Throwable in ProcessTask
reproduce problem
class ExceptionTest
we except get InvokeServerException when userProcessor.getBizClassLoader throw exception.
but we get InvokeTimeoutException
The Reason
https://github.com/sofastack/sofa-bolt/blob/master/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java#L395
RpcRequestProcessor#ProcessTask did not handle Throwable.
Summary by CodeRabbit