From b823e7e084145a8ed666e36ec43bf6820e99461e Mon Sep 17 00:00:00 2001 From: lepdou Date: Thu, 25 Aug 2022 18:59:59 +0800 Subject: [PATCH] remove location metadata (#535) --- CHANGELOG.md | 1 + .../tencent/cloud/polaris/registry/PolarisRegistration.java | 3 --- .../cloud/polaris/registry/PolarisRegistrationTest.java | 4 +--- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dba3c3fde..7011f7191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,3 +16,4 @@ - [fix:fix only config file metadata can be used in routing bug.](https://github.com/Tencent/spring-cloud-tencent/pull/518) - [optimizeļ¼šoptimize config module code](https://github.com/Tencent/spring-cloud-tencent/pull/520) - [feat:optimize pushgateway plugin.](https://github.com/Tencent/spring-cloud-tencent/pull/530) +- [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/535) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisRegistration.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisRegistration.java index 8665d26bb..ef704fb62 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisRegistration.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisRegistration.java @@ -109,9 +109,6 @@ public class PolarisRegistration implements Registration { instanceMetadata.putAll(staticMetadataManager.getMergedStaticMetadata()); - // location info will be putted both in metadata and instance's field - instanceMetadata.putAll(staticMetadataManager.getLocationMetadata()); - this.metadata = Collections.unmodifiableMap(instanceMetadata); } return metadata; diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/registry/PolarisRegistrationTest.java b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/registry/PolarisRegistrationTest.java index bcbaa35ce..420f61569 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/registry/PolarisRegistrationTest.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/registry/PolarisRegistrationTest.java @@ -74,7 +74,6 @@ public class PolarisRegistrationTest { // mock StaticMetadataManager StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class); doReturn(Collections.singletonMap("key1", "value1")).when(staticMetadataManager).getMergedStaticMetadata(); - doReturn(Collections.singletonMap("key2", "value2")).when(staticMetadataManager).getLocationMetadata(); polarisRegistration = new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties, polarisContext, staticMetadataManager); @@ -110,9 +109,8 @@ public class PolarisRegistrationTest { Map metadata = polarisRegistration.getMetadata(); assertThat(metadata).isNotNull(); assertThat(metadata).isNotEmpty(); - assertThat(metadata.size()).isEqualTo(4); + assertThat(metadata.size()).isEqualTo(3); assertThat(metadata.get("key1")).isEqualTo("value1"); - assertThat(metadata.get("key2")).isEqualTo("value2"); } @Test