AlexStocks commented on code in PR #3578:
URL: https://github.com/apache/dubbo-go/pull/3578#discussion_r4505079067
##########
metadata/info/metadata_info_test.go:
##########
@@ -285,3 +285,74 @@ func TestMetadataInfoGetServices(t *testing.T) {
func TestServiceInfoJavaClassName(t *testing.T) {
assert.Equalf(t, "org.apache.dubbo.metadata.MetadataInfo",
NewAppMetadataInfo("dubbo").JavaClassName(), "JavaClassName()")
}
+
+// goldenRevision was computed with Java 17 TreeMap.toString(), UTF-8 and MD5
Review Comment:
💭 注释声称 "computed with Java 17 TreeMap.toString(), UTF-8 and
MD5",但仓库里没有任何可复现该向量的 Java 代码/脚本。我按注释里的拼接串独立复算,MD5 确实等于
`47b3fb9aba75846310c970cee9daefcf`——所以向量的**字符串形态**是对的,但它证明的是「Go 实现 ==
注释里的字符串」,而不是「== Java 输出」。
建议把生成方式落到仓库里(哪怕是一段 30 行的 `tools/` 里的小 Java 程序或 CI 里可跑的脚本),或者在注释里直接给出 Java
侧源码路径 + 该方法的行为摘要。否则下一个改动 `toDescString()` 的人没有手段判断自己是否破坏了跨语言契约。
##########
metadata/info/metadata_info.go:
##########
@@ -49,7 +49,6 @@ func init() {
var IncludeKeys = gxset.NewSet(
Review Comment:
🟡 **参数集合与 Java 不是同一种过滤模型,所以摘要仍会对不上真实服务。**
Java 的 `ServiceInfo.extractServiceParams()` 在启用
`DefaultMetadataParamsFilter`(`@Activate`,默认生效)时做的是**黑名单**:
```java
excludedServiceParams = { monitor, bind.ip, bind.port, qos.enable, qos.host,
qos.port,
accept.foreign.ip, validation, interfaces, pid,
timestamp,
heartbeat.timeout, ipv6 };
```
也就是 `params = url.getParameters() - 这 13 个键`,剩下 `interface / side / anyhost
/ deprecated / retries / dubbo / service-name-mapping / methods / 自定义参数…` 全部参与
`toDescString()`。
而 Go 这里是 `IncludeKeys` **白名单**(13 个键),`NewServiceInfoWithURL` 只拷贝命中的键 +
`method.key` + `methods`。两种模型的差集就是:Java 有而 Go
没有的那些键(`interface`、`side`、`anyhost`、`deprecated`、`retries`、`dubbo`、自定义扩展参数……)。
结果:**同一个服务在 Java 与 Go 上算出的 revision 依然不同**,而 PR 描述/注释宣称的是「exact same
digest」。金标测试之所以过,是因为它的 params 里只放了白名单内的键,属于自洽而非跨语言验证。
建议二选一:
1. 若目标真是跨语言一致,把 `IncludeKeys` 改成与 Java 等价的排除名单(`timestamp`
已经在本次移除,方向是对的),并补一条**取自真实 Java provider 的 MetadataInfo JSON** 做 fixture;
2. 若本次只做「格式与摘要算法对齐」,把注释与 PR 描述里的 "exact same digest / byte-for-byte
identical" 改成 "same format and hash algorithm",另外开 issue 跟踪参数集合对齐。
无论选哪条,都请在 PR 描述里贴出 Java 侧依据(`MetadataInfo.calRevision` /
`ServiceInfo.toDescString` 的文件与行),这类跨语言契约后续很难有人重新推导。
--
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]