This is an automated email from the ASF dual-hosted git repository.

kevinclair pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 18bf819bc [type:bug]Fix bug, nacos register npe.
18bf819bc is described below

commit 18bf819bca7e3da69eb9959206c3cde5717f83a1
Author: wzhangNJ <[email protected]>
AuthorDate: Fri Nov 11 19:00:55 2022 +0800

    [type:bug]Fix bug, nacos register npe.
    
    Co-authored-by: 张文 <[email protected]>
---
 .../client/server/nacos/NacosClientServerRegisterRepository.java   | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-nacos/src/main/java/org/apache/shenyu/register/client/server/nacos/NacosClientServerRegisterRepository.java
 
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-nacos/src/main/java/org/apache/shenyu/register/client/server/nacos/NacosClientServerRegisterRepository.java
index 157d02752..d62283fef 100644
--- 
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-nacos/src/main/java/org/apache/shenyu/register/client/server/nacos/NacosClientServerRegisterRepository.java
+++ 
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-nacos/src/main/java/org/apache/shenyu/register/client/server/nacos/NacosClientServerRegisterRepository.java
@@ -26,6 +26,7 @@ import com.alibaba.nacos.api.naming.NamingFactory;
 import com.alibaba.nacos.api.naming.NamingService;
 import com.alibaba.nacos.api.naming.listener.NamingEvent;
 import com.alibaba.nacos.api.naming.pojo.Instance;
+import com.alibaba.nacos.common.utils.StringUtils;
 import com.google.common.collect.Lists;
 import org.apache.shenyu.common.constant.Constants;
 import org.apache.shenyu.common.constant.NacosPathConstants;
@@ -147,7 +148,11 @@ public class NacosClientServerRegisterRepository 
implements ShenyuClientServerRe
     }
 
     private void subscribeMetadata(final String serviceConfigName) {
-        registerMetadata(readData(serviceConfigName));
+        String content = readData(serviceConfigName);
+        if (StringUtils.isEmpty(content)) {
+            return;
+        }
+        registerMetadata(content);
         LOGGER.info("subscribe metadata: {}", serviceConfigName);
         try {
             configService.addListener(serviceConfigName, defaultGroup, new 
Listener() {

Reply via email to