AlexStocks commented on code in PR #3498:
URL: https://github.com/apache/dubbo-go/pull/3498#discussion_r3680891688
##########
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] 当前 Head 仍可稳定复现该兼容性破坏。
我重新以实时 Base `bcd6aa42` 和 Head `9b479448` 建立相同的外部模块:模块同时导入 dubbo-go 的
Hessian2 包,并直接调用 hessian2 v1.12.5 的公开函数 `hessian.NewHessianCodec`。Base 下 `go
list -m all` 选择 `github.com/apache/dubbo-go-hessian2 v1.12.5`,`go build ./...`
退出 0;替换为 Head 后 MVS 选择 v1.13.2,编译稳定失败:`undefined: hessian.NewHessianCodec`。截至
2026-07-30,`go list -m ...@latest` 返回的最新版本仍是 v1.13.2,上游没有恢复兼容入口的新版本。
因此这不是仓库内部迁移是否能编译的问题,而是本行升级会把 hessian2 同一 major 内的公开 API 删除传递给真实下游。需要先在
hessian2 v1.x 恢复 Deprecated 兼容入口并发布,再升级这里;或者按语义化版本发布新的
major,并明确迁移边界。还应保留混合模块编译测试,覆盖 Go MVS 的实际选择结果。
##########
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] 当前 Head 仍未保留这里的已发布字符串转换语义。
我把同一个外部包测试分别替换到实时 Base `bcd6aa42` 与 Head `9b479448`:输入 `java exception:
com.example.Err - something went wrong` 时,测试要求旧契约
`ExceptionClass=java.lang.Exception`、`ExceptionMessage=com.example.Err -
something went wrong`。Base 测试退出 0;Head 稳定失败,实际 `ExceptionClass` 为
`com.example.Err`。PR 新增的 `generic_exception_compat_test.go` 只检查 string 分支返回非
nil,没有断言这两个字段,所以 Head 的定向测试和 CI 仍会绿色。
请在这个 Deprecated 转发入口单独保留旧 string 分支,其余内部协议路径继续直接调用新版 hessian2
实现,并把新增测试改为精确断言两个字段;修复后应保持同一 Base/Head 探针由失败转为通过。
--
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]