From bc228ce47c4f239cc117cdbe38c382bd8326b61b Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Thu, 25 Apr 2024 17:05:02 +0800 Subject: [PATCH] fix:fix NullPointerException when properties contain kv with null value. --- CHANGELOG.md | 1 + pom.xml | 2 +- .../config/listener/PolarisConfigListenerContext.java | 8 ++++++++ spring-cloud-tencent-dependencies/pom.xml | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 168274ddc6..29813ebfed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ - [feat: support nacos namespace mapping](https://github.com/Tencent/spring-cloud-tencent/pull/1191) - [fix:fix sct-all wrong spring boot version obtain.](https://github.com/Tencent/spring-cloud-tencent/pull/1204) - fix:fix restTemplateCustomizer bean conflict causing service to fail to start properly. +- fix:fix NullPointerException when properties contain kv with null value. diff --git a/pom.xml b/pom.xml index 402cf97b38..87b3718b69 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ - 1.13.1-Hoxton.SR12 + 1.13.2-Hoxton.SR12 5.2.25.RELEASE diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigListenerContext.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigListenerContext.java index 0c2df31493..85bd2ab424 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigListenerContext.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigListenerContext.java @@ -118,6 +118,11 @@ public static ExecutorService executor() { * @param ret origin properties map */ static void initialize(Map ret) { + for (Map.Entry entry : ret.entrySet()) { + if (entry.getValue() == null) { + ret.put(entry.getKey(), ""); + } + } properties.putAll(ret); } @@ -144,6 +149,9 @@ static Map merge(Map ret) { ret.keySet().parallelStream().forEach(key -> { Object oldValue = properties.getIfPresent(key); Object newValue = ret.get(key); + if (newValue == null) { + newValue = ""; + } if (oldValue != null) { if (!newValue.equals(oldValue)) { properties.put(key, newValue); diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 2cfa7bdfac..f6357bb759 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -70,7 +70,7 @@ - 1.13.1-Hoxton.SR12 + 1.13.2-Hoxton.SR12 1.15.0