AlexStocks commented on code in PR #3618:
URL: https://github.com/apache/dubbo-go/pull/3618#discussion_r3749871683


##########
filter/generic/filter.go:
##########
@@ -197,10 +197,7 @@ func (f *genericFilter) OnResponse(_ context.Context, res 
result.Result, invoker
                return res
        }
 
-       // Check if data is a map type that needs to be deserialized
-       dataValue := reflect.ValueOf(data)
-       if dataValue.Kind() != reflect.Map && dataValue.Kind() != reflect.Slice 
{
-               // If data is not a map or slice, it's already a primitive 
type, no need to deserialize
+       if !shouldRealizeTypedResult(data, generic) {

Review Comment:
   [P1] 保留 `GenericService.Invoke` 的 raw `any` 返回语义
   
   `GenericService.Invoke` 的公开返回类型是 `any`,proxy 因此会把 invocation reply 建成 
`*interface{}`。这里对 `gson/protobuf-json` 无条件进入 typed realization 后,Gson 会尝试把 
JSON 字符串反序列化成 `interface{}` 并报 `the type of obj(=interface {}) should be 
hessian pojo`,原本可直接返回 raw JSON 的 `Invoke` 变成 RPC 错误。隔离探针在 Base `2edb07e4` 通过、当前 
Head `575c2cac` 失败。请只对具体 typed reply 做自动 realization,`interface{}`/`any` 容器应保留 
raw 结果,并补公开 `NewGenericService -> Invoke` 的 gson/protobuf-json 回归测试。



##########
filter/generic/service.go:
##########
@@ -79,19 +102,19 @@ func (s *GenericService) InvokeWithType(ctx 
context.Context, methodName string,
                return nil
        }
 
-       // Get the element type that the pointer points to
        replyType := replyValue.Elem().Type()
-
-       // Use MapGeneralizer to realize the map result to the target struct
-       g := generalizer.GetMapGeneralizer()
        realized, err := realizeResult(result, replyType, g)

Review Comment:
   [P1] 在 Gson realization 前规范化 reply 的指针层级
   
   `validateReplyPointer` 接受 `&reply`,且 assignment helper 也支持 pointer 
target;但当调用者使用常见的 `var reply *User; InvokeWithType(..., &reply)` 时,这里把 `*User` 
直接交给 Gson generalizer。后者执行 `reflect.New(*User)` 得到 `**User`,无法满足 
`hessian.POJO`,当前 Head 探针稳定报 `the type of obj(=*generic.probeGsonUser) should 
be hessian pojo`。请像 Protobuf-JSON 一样先剥离/规范化 pointer target,或在共享层正确分配目标,并补 Gson 
`**T` reply 回归测试。



-- 
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