diff --git a/pkg/codec.go b/pkg/codec.go index b89463c7..9dbddf89 100644 --- a/pkg/codec.go +++ b/pkg/codec.go @@ -23,6 +23,7 @@ import ( "context" "fmt" + "github.com/bytedance/gopkg/cloud/metainfo" hessian2_exception "github.com/kitex-contrib/codec-dubbo/pkg/hessian2/exception" "github.com/kitex-contrib/codec-dubbo/registries" @@ -453,22 +454,17 @@ func processAttachments(decoder iface.Decoder, message remote.Message) error { if attachments, ok := attachmentsRaw.(map[interface{}]interface{}); ok { transStrMap := map[string]string{} - transIntMap := map[uint16]string{} for keyRaw, val := range attachments { if key, ok := keyRaw.(string); ok { message.Tags()[key] = val if v, ok := val.(string); ok { - transStrMap[key] = v - } - } - if uint16Key, ok := keyRaw.(uint16); ok { - if v, ok := val.(string); ok { - transIntMap[uint16Key] = v + // The prefix needs to be added + transStrMap[metainfo.PrefixTransient+key] = v } } } + message.TransInfo().PutTransStrInfo(transStrMap) - message.TransInfo().PutTransIntInfo(transIntMap) return nil } diff --git a/pkg/dubbo_spec/attachment.go b/pkg/dubbo_spec/attachment.go index 45b3d4e3..c4a11960 100644 --- a/pkg/dubbo_spec/attachment.go +++ b/pkg/dubbo_spec/attachment.go @@ -23,6 +23,7 @@ import ( "strconv" "time" + "github.com/bytedance/gopkg/cloud/metainfo" "github.com/cloudwego/kitex/pkg/remote" ) @@ -32,9 +33,11 @@ const ( INTERFACE_KEY = "interface" VERSION_KEY = "version" TIMEOUT_KEY = "timeout" + + lenPT = len(metainfo.PrefixTransient) ) -type Attachment = map[interface{}]interface{} +type Attachment = map[string]interface{} func NewAttachment(path, group, iface, version string, timeout time.Duration, transInfo remote.TransInfo) Attachment { result := Attachment{} @@ -53,11 +56,13 @@ func NewAttachment(path, group, iface, version string, timeout time.Duration, tr if timeout > 0 { result[TIMEOUT_KEY] = strconv.Itoa(int(timeout.Milliseconds())) } - for k, v := range transInfo.TransIntInfo() { - result[k] = v - } for k, v := range transInfo.TransStrInfo() { - result[k] = v + // The prefix needs to be removed + if len(k) > lenPT { + result[k[lenPT:]] = v + } else { + result[k] = v + } } return result }