This is an automated email from the ASF dual-hosted git repository.

alexstocks 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 b97a7f5de Fix: Triple protocol streaming does not correctly handle 
context ctx attachments errors (#2810)
b97a7f5de is described below

commit b97a7f5deed86aee4f66eb6735948e3414a31a24
Author: 1kasa <[email protected]>
AuthorDate: Sun Mar 23 21:45:50 2025 +0800

    Fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors (#2810)
    
    * fix: Same address cannot distinguish different registry center
    
    * fix: Same address cannot distinguish different registry center
    
    * registry.namespace is set to a constant,
    
    * Fix (Server): Avoid error reporting warning logs when detecting EOF via 
Peek to properly close the connection
    
    * Fix (Server): Avoid error reporting warning logs when detecting EOF via 
Peek to properly close the connection
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Triple protocol streaming does not correctly handle context ctx 
attachments errors
    
    * fix: Code format
    
    * fix: Code format
---
 common/constant/key.go                                   | 5 +++++
 protocol/triple/triple_protocol/handler_compat.go        | 5 +++--
 protocol/triple/triple_protocol/handler_stream_compat.go | 8 ++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/common/constant/key.go b/common/constant/key.go
index 6bd28a09f..08685de28 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -463,3 +463,8 @@ const (
 const (
        DefaultPriority = 0
 )
+
+const (
+       TripleGoInterfaceName = "XXX_TRIPLE_GO_INTERFACE_NAME"
+       TripleGoMethodName    = "XXX_TRIPLE_GO_METHOD_NAME"
+)
diff --git a/protocol/triple/triple_protocol/handler_compat.go 
b/protocol/triple/triple_protocol/handler_compat.go
index 5d4b9ebe7..6b4145ec9 100644
--- a/protocol/triple/triple_protocol/handler_compat.go
+++ b/protocol/triple/triple_protocol/handler_compat.go
@@ -33,6 +33,7 @@ import (
 )
 
 import (
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
        dubbo_protocol "dubbo.apache.org/dubbo-go/v3/protocol"
 )
 
@@ -146,10 +147,10 @@ func generateCompatUnaryHandlerFunc(
                ctx = metadata.NewIncomingContext(ctx, 
metadata.MD(conn.ExportableHeader()))
                // staticcheck error: SA1029. dubbo3 code needs to make use of 
"XXX_TRIPLE_GO_METHOD_NAME"
                //nolint:staticcheck
-               ctx = context.WithValue(ctx, "XXX_TRIPLE_GO_METHOD_NAME", 
method)
+               ctx = context.WithValue(ctx, constant.TripleGoMethodName, 
method)
                // staticcheck error: SA1029. Stub code generated by 
protoc-gen-go-triple makes use of "XXX_TRIPLE_GO_INTERFACE_NAME" directly
                //nolint:staticcheck
-               ctx = context.WithValue(ctx, "XXX_TRIPLE_GO_INTERFACE_NAME", 
procedure)
+               ctx = context.WithValue(ctx, constant.TripleGoInterfaceName, 
procedure)
                // todo(DMwangnima): deal with XXX_TRIPLE_GO_GENERIC_PAYLOAD
                respRaw, err := unary(srv, ctx, decodeFunc, 
compatInterceptor.compatUnaryServerInterceptor)
                if err != nil {
diff --git a/protocol/triple/triple_protocol/handler_stream_compat.go 
b/protocol/triple/triple_protocol/handler_stream_compat.go
index 6a0fbb347..f49e346f5 100644
--- a/protocol/triple/triple_protocol/handler_stream_compat.go
+++ b/protocol/triple/triple_protocol/handler_stream_compat.go
@@ -26,6 +26,10 @@ import (
        "github.com/dubbogo/grpc-go/metadata"
 )
 
+import (
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+)
+
 type compatHandlerStream struct {
        ctx  context.Context
        conn StreamingHandlerConn
@@ -92,6 +96,10 @@ func generateCompatStreamHandlerFunc(
        interceptor Interceptor,
 ) StreamingHandlerFunc {
        implementation := func(ctx context.Context, conn StreamingHandlerConn) 
error {
+               ctx = metadata.NewIncomingContext(ctx, 
metadata.MD(conn.ExportableHeader()))
+               // staticcheck error: SA1029. Stub code generated by 
protoc-gen-go-triple makes use of "XXX_TRIPLE_GO_INTERFACE_NAME" directly
+               //nolint:staticcheck
+               ctx = context.WithValue(ctx, constant.TripleGoInterfaceName, 
procedure)
                stream := &compatHandlerStream{
                        ctx:  ctx,
                        conn: conn,

Reply via email to