Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(metadata): remove unused CalAndGetRevision method
No callers in production code. Go's MetadataInfo.Revision is set
externally by the registry/customizer path, unlike Java where
calAndGetRevision() manages the revision internally. CalRevision
remains as the public API for revision calculation.
  • Loading branch information
Qiao-yq committed Jun 11, 2026
commit 1c998e02f21735172bf87455a182bd373c527451
9 changes: 0 additions & 9 deletions metadata/info/metadata_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,6 @@ func (info *MetadataInfo) ReplaceExportedServices(urls []*common.URL) {
}
}

// CalAndGetRevision calculates and updates the revision for this MetadataInfo.
// The revision is derived from the canonical ServiceInfo representation,
// ensuring strong binding between revision and serialized metadata content.
// Aligned with Java dubbo MetadataInfo.calAndGetRevision().
func (info *MetadataInfo) CalAndGetRevision() string {
info.Revision = CalRevision(info.App, info.Services)
return info.Revision
}

func (info *MetadataInfo) findExportedServiceURL(matchKey string) *common.URL {
for _, urls := range info.exportedServiceURLs {
for _, serviceURL := range urls {
Expand Down
24 changes: 0 additions & 24 deletions metadata/info/metadata_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,3 @@ func TestServiceInfoGetMatchKey(t *testing.T) {
func TestServiceInfoJavaClassName(t *testing.T) {
assert.Equalf(t, "org.apache.dubbo.metadata.MetadataInfo", NewAppMetadataInfo("dubbo").JavaClassName(), "JavaClassName()")
}

func TestMetadataInfoCalAndGetRevision(t *testing.T) {
svcURL, err := common.NewURL(
"dubbo://127.0.0.1:20880/com.example.TestService",
common.WithParamsValue(constant.ApplicationKey, "test-app"),
common.WithParamsValue(constant.GroupKey, "groupA"),
common.WithParamsValue(constant.VersionKey, "1.0.0"),
common.WithMethods([]string{"sayHello"}),
)
require.NoError(t, err)

info := NewAppMetadataInfo("")
info.AddService(svcURL)

// 1. Call CalAndGetRevision — should update info.Revision in-place
rev := info.CalAndGetRevision()

assert.NotEmpty(t, rev)
assert.Equal(t, rev, info.Revision, "CalAndGetRevision should update info.Revision in-place")

// 2. Result should match CalRevision for the same input
assert.Equal(t, CalRevision(info.App, info.Services), rev,
"CalAndGetRevision should return the same result as CalRevision")
}