AlexStocks commented on code in PR #3451:
URL: https://github.com/apache/dubbo-go/pull/3451#discussion_r4521778361
##########
protocol/triple/triple.go:
##########
@@ -157,7 +157,7 @@ func (tp *TripleProtocol) Refer(url *common.URL)
base.Invoker {
invoker, err = NewTripleInvoker(url)
} else {
// stub code generated by old protoc-gen-go-triple
- invoker, err = NewDubbo3Invoker(url)
+ logger.Error("[Server][Triple] dubbo3(old triple) and IDL-mode
are not supported by dubbo-go any more, please use Triple protocol and
regenerate stub code using latest
[protoc-gen-go-triple](https://github.com/apache/dubbo-go/tree/main/tools/protoc-gen-go-triple)")
Review Comment:
[P1] Refer 在旧 stub / IDL 模式下返回 (nil, nil) 并向 invokers 追加 nil
触发条件:消费方 URL 不含 `ClientInfoKey`、`IDLMode != NONIDL` 且非泛化调用,即使用旧
protoc-gen-go-triple 生成 stub 的既有用户。
实际影响:else 分支只写日志,`invoker` 与 `err` 都保持零值,随后的 `if err != nil` 不成立,控制流继续执行
`tp.SetInvokers(invoker)` 与 `return invoker`。`BaseProtocol.SetInvokers` 直接
`append(bp.invokers, invoker)`(protocol/base/base_protocol.go 的 SetInvokers),于是
nil 被写入 invokers 列表;Refer 返回 nil invoker 且 error 为 nil,调用方无法区分引用失败与引用成功,首次
Invoke 会对 nil Invoker 解引用 panic。
证据:本行的 else 分支没有 `return`;同一函数的其它失败分支(err != nil)均 `return
nil`;`SetInvokers` 无 nil 检查。
修复方向:该分支在 `logger.Error` 之后立即 `return nil`(或返回明确错误),不要继续走到 `SetInvokers`。
##########
protocol/triple/server.go:
##########
@@ -276,7 +273,7 @@ func (s *Server) registerServiceHandlers(invoker
base.Invoker, info *common.Serv
s.handleServiceWithInfo(intfName, invoker, reflectInfo,
hanOpts...)
s.saveServiceInfo(intfName, reflectInfo, openapiGroup,
url.Group(), url.Version())
} else {
- s.compatHandleService(url, intfName, url.Group(),
url.Version(), hanOpts...)
+ logger.Error("[Server][Triple] dubbo3(old triple) and IDL-mode
are not supported by dubbo-go any more, please use Triple protocol")
Review Comment:
[P2] 旧 triple 服务导出后仍被标记为 health Serving
触发条件:provider 使用旧 protoc-gen-go-triple stub(IDL 模式、URL 无 ServiceInfo)导出
Triple 服务。
实际影响:`registerServiceHandlers` 走到本行时只记录一条错误日志,不注册任何 handler;但 `Export` 在
`openServer` 成功返回后无条件执行
`internal.HealthSetServingStatusServing(serviceKey)`。结果是对外(注册中心与 health
接口)报告服务已就绪,实际请求会落到没有 handler 的 server 上,故障被推迟到首次调用才暴露,且没有启动期失败信号。
证据:本行只记日志、无 error 返回;protocol/triple/triple.go 的 Export 在 `openServer`
成功后紧接着设置 Serving 状态。
修复方向:让该分支返回错误并由 `Export` 失败退出(与 `openServer` 的其它错误路径一致),或在未注册 handler 时不设置
Serving 状态。
--
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]