AlexStocks commented on code in PR #3594:
URL: https://github.com/apache/dubbo-go/pull/3594#discussion_r3718060892
##########
filter/generic/service.go:
##########
@@ -19,40 +19,64 @@ package generic
import (
"context"
- "reflect"
)
import (
hessian "github.com/apache/dubbo-go-hessian2"
)
import (
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/filter/generic/generalizer"
)
// GenericService uses for generic invoke for service call
type GenericService struct {
Invoke func(ctx context.Context, methodName string, types
[]string, args []hessian.Object) (any, error) `dubbo:"$invoke"`
referenceStr string
+ generic string
}
// NewGenericService returns a GenericService instance
func NewGenericService(referenceStr string) *GenericService {
- return &GenericService{referenceStr: referenceStr}
+ return &GenericService{referenceStr: referenceStr, generic:
constant.GenericSerializationDefault}
}
// Reference gets referenceStr from GenericService
func (s *GenericService) Reference() string {
return s.referenceStr
}
+// SetGenericType sets the generic mode used by InvokeWithType to realize
typed results.
+func (s *GenericService) SetGenericType(generic string) error {
+ if generic == "" {
+ generic = constant.GenericSerializationDefault
Review Comment:
[P1] 保持空 generic 的非泛化语义
`WithGenericType("")` 会覆盖 `NewGenericService` 预置的
`true`;`ValidateGenericType`、`IsGenericMode` 和 filter/Triple
路径都把空值定义为非泛化。但这里又把同一个最终引用值改成 `true`,导致底层 connection 不走泛化路径,而 `InvokeWithType`
却按 Map 泛化结果反序列化。我在当前 Head 上按 `WithGeneric() -> WithGenericType("") ->
SetGenericType(final Reference.Generic)` 建立探针,稳定失败为 `reference mode "" became
typed-result mode "true"`。请保留空值并像 `false` 一样拒绝 typed result,或者在
`NewGenericService` 建立引用前明确拒绝空值,并补这个 option 覆盖顺序的回归测试。
--
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]