From 3b0eea0033178dd9b27e059c6dcaa3478b9aa153 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Wed, 8 Jun 2022 10:33:09 +0800 Subject: [PATCH] fix:use 1.6.1 version of polaris-java. (#221) --- CHANGELOG.md | 2 -- changes/changes-1.5.1.md | 5 ++++ pom.xml | 23 ++++++------------- ...sRefreshApplicationReadyEventListener.java | 2 +- .../common/metadata/MetadataContext.java | 12 +++++++--- .../cloud/common/util/JacksonUtils.java | 7 +++++- spring-cloud-tencent-dependencies/pom.xml | 11 +++++++-- .../metadata-transfer-example/README.md | 3 ++- .../cloud/polaris/config/example/Person.java | 8 +++---- 9 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 changes/changes-1.5.1.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a846de737..06c1f8175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,3 @@ # Change Log --- -- [fix:fix consul connect bug.](https://github.com/Tencent/spring-cloud-tencent/pull/217) -- [fix:fix PolarisRegistration cannot get metadata bug.](https://github.com/Tencent/spring-cloud-tencent/pull/218) diff --git a/changes/changes-1.5.1.md b/changes/changes-1.5.1.md new file mode 100644 index 000000000..a846de737 --- /dev/null +++ b/changes/changes-1.5.1.md @@ -0,0 +1,5 @@ +# Change Log +--- + +- [fix:fix consul connect bug.](https://github.com/Tencent/spring-cloud-tencent/pull/217) +- [fix:fix PolarisRegistration cannot get metadata bug.](https://github.com/Tencent/spring-cloud-tencent/pull/218) diff --git a/pom.xml b/pom.xml index 120684410..3e6f7a8b1 100644 --- a/pom.xml +++ b/pom.xml @@ -86,14 +86,11 @@ - 1.5.1-Hoxton.SR9 + 1.5.2-Hoxton.SR9 Hoxton.SR9 - - 1.2.7 - 0.8.3 3.2.0 @@ -109,15 +106,6 @@ - - - org.springframework.cloud - spring-cloud-dependencies - ${spring.cloud.version} - pom - import - - com.tencent.cloud @@ -127,10 +115,13 @@ import + - ch.qos.logback - logback-classic - ${logback.version} + org.springframework.cloud + spring-cloud-dependencies + ${spring.cloud.version} + pom + import diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/refresh/PolarisRefreshApplicationReadyEventListener.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/refresh/PolarisRefreshApplicationReadyEventListener.java index d80accc57..9591cb389 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/refresh/PolarisRefreshApplicationReadyEventListener.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/refresh/PolarisRefreshApplicationReadyEventListener.java @@ -40,7 +40,7 @@ import static com.tencent.cloud.polaris.discovery.refresh.PolarisServiceStatusCh */ public class PolarisRefreshApplicationReadyEventListener implements ApplicationListener, ApplicationEventPublisherAware { - private static final Logger LOG = LoggerFactory.getLogger(PolarisRefreshConfiguration.class); + private static final Logger LOG = LoggerFactory.getLogger(PolarisRefreshApplicationReadyEventListener.class); private static final int DELAY = 60; private final PolarisDiscoveryHandler polarisDiscoveryHandler; private final PolarisServiceStatusChangeListener polarisServiceStatusChangeListener; diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java index e7d6c7948..90148cd22 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java @@ -24,6 +24,8 @@ import java.util.concurrent.ConcurrentHashMap; import com.tencent.cloud.common.util.ApplicationContextAwareUtils; import com.tencent.cloud.common.util.JacksonUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; @@ -38,6 +40,7 @@ public class MetadataContext { * transitive context. */ public static final String FRAGMENT_TRANSITIVE = "transitive"; + private static final Logger LOG = LoggerFactory.getLogger(MetadataContext.class); /** * Namespace of local instance. */ @@ -48,9 +51,6 @@ public class MetadataContext { */ public static String LOCAL_SERVICE; - - private final Map> fragmentContexts; - static { String namespace = ApplicationContextAwareUtils .getProperties("spring.cloud.polaris.namespace"); @@ -60,6 +60,8 @@ public class MetadataContext { } if (StringUtils.isEmpty(namespace)) { + LOG.error("namespace should not be blank. please configure spring.cloud.polaris.namespace or " + + "spring.cloud.polaris.discovery.namespace"); throw new RuntimeException("namespace should not be blank. please configure spring.cloud.polaris.namespace or " + "spring.cloud.polaris.discovery.namespace"); } @@ -75,12 +77,16 @@ public class MetadataContext { } if (StringUtils.isEmpty(serviceName)) { + LOG.error("service name should not be blank. please configure spring.cloud.polaris.service or " + + "spring.cloud.polaris.discovery.service or spring.application.name"); throw new RuntimeException("service name should not be blank. please configure spring.cloud.polaris.service or " + "spring.cloud.polaris.discovery.service or spring.application.name"); } LOCAL_SERVICE = serviceName; } + private final Map> fragmentContexts; + public MetadataContext() { this.fragmentContexts = new ConcurrentHashMap<>(); } diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/JacksonUtils.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/JacksonUtils.java index 628c718a1..a30fc8bc1 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/JacksonUtils.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/JacksonUtils.java @@ -69,7 +69,12 @@ public final class JacksonUtils { public static Map deserialize2Map(String jsonStr) { try { if (StringUtils.hasText(jsonStr)) { - return OM.readValue(jsonStr, Map.class); + Map temp = OM.readValue(jsonStr, Map.class); + Map result = new HashMap<>(); + temp.forEach((key, value) -> { + result.put(String.valueOf(key), String.valueOf(value)); + }); + return result; } return new HashMap<>(); } diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 529b4e7b9..25031745d 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -70,8 +70,9 @@ - 1.5.1-Hoxton.SR9 - 1.6.0 + 1.5.2-Hoxton.SR9 + 1.6.1 + 1.2.7 4.5.1 1.12.10 @@ -146,6 +147,12 @@ ${revision} + + ch.qos.logback + logback-classic + ${logback.version} + + org.mockito mockito-inline diff --git a/spring-cloud-tencent-examples/metadata-transfer-example/README.md b/spring-cloud-tencent-examples/metadata-transfer-example/README.md index 8697f1a26..c89a12d7b 100644 --- a/spring-cloud-tencent-examples/metadata-transfer-example/README.md +++ b/spring-cloud-tencent-examples/metadata-transfer-example/README.md @@ -2,7 +2,8 @@ ## Example Introduction -This example shows how to use ```spring-cloud-starter-tencent-metadata-transfer`` in Spring Cloud project for its features. +This example shows how to use ```spring-cloud-starter-tencent-metadata-transfer``` in Spring Cloud project for its +features. This example contains ```metadata-callee-service```、```metadata-caller-service```. diff --git a/spring-cloud-tencent-examples/polaris-config-example/src/main/java/com/tencent/cloud/polaris/config/example/Person.java b/spring-cloud-tencent-examples/polaris-config-example/src/main/java/com/tencent/cloud/polaris/config/example/Person.java index 492af0a8b..1d97d1fb9 100644 --- a/spring-cloud-tencent-examples/polaris-config-example/src/main/java/com/tencent/cloud/polaris/config/example/Person.java +++ b/spring-cloud-tencent-examples/polaris-config-example/src/main/java/com/tencent/cloud/polaris/config/example/Person.java @@ -34,19 +34,19 @@ public class Person { private int age; - String getName() { + public String getName() { return name; } - void setName(String name) { + public void setName(String name) { this.name = name; } - int getAge() { + public int getAge() { return age; } - void setAge(int age) { + public void setAge(int age) { this.age = age; }