diff --git a/changes/changes-1.13.0.md b/changes/changes-1.13.0.md index 168274ddc..29813ebfe 100644 --- a/changes/changes-1.13.0.md +++ b/changes/changes-1.13.0.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/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 0c2df3149..85bd2ab42 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 final class PolarisConfigListenerContext { * @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 @@ public final class PolarisConfigListenerContext { 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);