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


##########
go.mod:
##########
@@ -7,7 +7,7 @@ require (
        github.com/Workiva/go-datastructures v1.0.52
        github.com/alibaba/sentinel-golang v1.0.4
        github.com/apache/dubbo-getty v1.4.10
-       github.com/apache/dubbo-go-hessian2 v1.12.5
+       github.com/apache/dubbo-go-hessian2 v1.13.2

Review Comment:
   [P1] 避免把 hessian2 的破坏性删除传递给下游
   
   `v1.13.0` 明确删除了 `HessianCodec`、`Request`、`Response`、`ReflectResponse` 等公开 
API,本行升级到 `v1.13.2` 后,Go MVS 会让同时使用 dubbo-go 和 hessian2 的下游被强制选到该版本。独立消费者探针在 
Base(hessian2 v1.12.5)可编译,替换为当前 Head 后稳定报 `undefined: 
hessian.NewHessianCodec`;仓库内部 CI 不会覆盖这种外部组合。建议先在 hessian2 v1.x 恢复这些符号的 
Deprecated 兼容入口并发布新版本,再升级这里;同时增加一个同时导入 dubbo-go 与旧 hessian2 公开 API 的外部模块编译测试。



##########
protocol/dubbo/hessian2/hessian_response.go:
##########
@@ -34,56 +34,24 @@ import (
        perrors "github.com/pkg/errors"
 )
 
-// DubboResponse dubbo response
-type DubboResponse struct {
-       RspObj      any
-       Exception   error
-       Attachments map[string]any
-}
-
-// GenericException keeps Java exception class and message.
-type GenericException struct {
-       ExceptionClass   string
-       ExceptionMessage string
-}
-
-// Error returns a readable error string.
-func (e GenericException) Error() string {
-       if e.ExceptionClass == "" {
-               return e.ExceptionMessage
-       }
-       if e.ExceptionMessage == "" {
-               return e.ExceptionClass
-       }
-       return "java exception: " + e.ExceptionClass + " - " + 
e.ExceptionMessage
-}
+// GenericException is a type alias of hessian.GenericException for backward
+// compatibility.
+//
+// Deprecated: Use hessian.GenericException from 
github.com/apache/dubbo-go-hessian2 instead.
+type GenericException = hessian.GenericException
 
 // ToGenericException converts decoded exception to GenericException when 
possible.
+//
+// Deprecated: Use hessian.ToGenericException from 
github.com/apache/dubbo-go-hessian2 instead.
 func ToGenericException(expt any) (*GenericException, bool) {
-       switch v := expt.(type) {
-       case *GenericException:
-               return v, true
-       case GenericException:
-               return &v, true
-       case *java_exception.DubboGenericException:
-               return &GenericException{ExceptionClass: v.ExceptionClass, 
ExceptionMessage: v.ExceptionMessage}, true
-       case java_exception.DubboGenericException:
-               return &GenericException{ExceptionClass: v.ExceptionClass, 
ExceptionMessage: v.ExceptionMessage}, true
-       case java_exception.Throwabler:
-               return &GenericException{ExceptionClass: v.JavaClassName(), 
ExceptionMessage: v.Error()}, true
-       case string:
-               return parseLegacyException(v), true
-       }
-       return nil, false
+       return hessian.ToGenericException(expt)

Review Comment:
   [P1] 兼容入口仍需保留旧的字符串转换语义
   
   这个转发会改变已发布 `ToGenericException` 的结果。对输入 `java exception: com.example.Err - 
something went wrong`,Base 返回 
`ExceptionClass=java.lang.Exception`、`ExceptionMessage=com.example.Err - 
something went wrong`,当前 Head 则返回 
`ExceptionClass=com.example.Err`、`ExceptionMessage=something went 
wrong`;依赖旧字段值做分类或日志处理的调用方会静默改变行为。建议仅在这个 Deprecated 兼容函数中保留旧的 string 
分支,其余类型再转发给上游;内部协议路径仍可直接使用新版函数。新增兼容测试还应精确断言该字符串场景的两个字段,而不只是断言非 nil。



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