This is an automated email from the ASF dual-hosted git repository.
ruinova pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 47d80e2aa fix: replace panic with error handling in
compatUnaryServerInterceptor (#3064)
47d80e2aa is described below
commit 47d80e2aafe99899d9b35761f2d7708cce183638
Author: zbchi <[email protected]>
AuthorDate: Sun Nov 9 21:04:49 2025 +0800
fix: replace panic with error handling in compatUnaryServerInterceptor
(#3064)
---
protocol/triple/triple_protocol/handler_compat.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/protocol/triple/triple_protocol/handler_compat.go
b/protocol/triple/triple_protocol/handler_compat.go
index 594a3729c..69dadbe17 100644
--- a/protocol/triple/triple_protocol/handler_compat.go
+++ b/protocol/triple/triple_protocol/handler_compat.go
@@ -25,6 +25,8 @@ import (
)
import (
+ "github.com/dubbogo/gost/log/logger"
+
"github.com/dubbogo/grpc-go"
"github.com/dubbogo/grpc-go/metadata"
"github.com/dubbogo/grpc-go/status"
@@ -64,13 +66,13 @@ func (t *tripleCompatInterceptor)
compatUnaryServerInterceptor(ctx context.Conte
}
dubbo3RespRaw, err := handler(ctx, typed.Any())
if dubbo3RespRaw == nil && err == nil {
- // This is going to panic during serialization.
Debugging is much easier
- // if we panic here instead, so we can include the
procedure name.
- panic(fmt.Sprintf("%s returned nil resp and nil error",
t.procedure)) //nolint: forbidigo
+ logger.Errorf("Procedure %s unexpectedly returned both
nil response and nil error, which should not happen", t.procedure)
+ return nil, errorf(CodeInternal, "Procedure %s
unexpectedly returned both nil response and nil error, which should not
happen", t.procedure)
}
dubbo3Resp, ok := dubbo3RespRaw.(*dubbo_protocol.RPCResult)
if !ok {
- panic(fmt.Sprintf("%+v is not of type *RPCResult",
dubbo3RespRaw))
+ logger.Errorf("Procedure %s returned an unexpected
response type. Expected *dubbo_protocol.RPCResult, but got %T", t.procedure,
dubbo3RespRaw)
+ return nil, errorf(CodeInternal, "Procedure %s returned
an unexpected response type. Expected *dubbo_protocol.RPCResult, but got %T",
t.procedure, dubbo3RespRaw)
}
dubbo3Err, ok := compatError(err)
if ok {