Copilot commented on code in PR #3514:
URL: https://github.com/apache/brpc/pull/3514#discussion_r3910183900


##########
src/brpc/selective_channel.cpp:
##########
@@ -394,8 +395,14 @@ void SubDone::Run() {
         main_cntl->_error_code = _cntl._error_code;
     } else {
         if (_cntl._response != main_cntl->_response) {
-            main_cntl->_response->GetReflection()->Swap(
-                main_cntl->_response, _cntl._response);
+            NonreflectableMessageBase* nr_msg =
+                dynamic_cast<NonreflectableMessageBase*>(main_cntl->_response);
+            if (nr_msg != nullptr) {
+                CHECK(nr_msg->CopyFromSameType(*_cntl._response));
+            } else {
+                main_cntl->_response->GetReflection()->Swap(
+                    main_cntl->_response, _cntl._response);
+            }

Review Comment:
   `CHECK(nr_msg->CopyFromSameType(*_cntl._response))` will still hard-crash 
the process if the sub-call response type doesn't match the main response type 
(or if `_cntl._response` is unexpectedly nonreflectable but not compatible). 
Since this code path is explicitly handling non-reflectable messages to avoid 
crashes, it should fail the RPC gracefully (set controller failed) instead of 
aborting the whole process.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to