You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ra...@apache.org on 2021/06/30 01:58:10 UTC

[dubbo-admin] branch develop updated: fix subscribe service will block admin startup (#779)

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

ranke pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git


The following commit(s) were added to refs/heads/develop by this push:
     new dd0fd7a  fix subscribe service will block admin startup (#779)
dd0fd7a is described below

commit dd0fd7ac934d2e3589c06071678c5b5dae5906e0
Author: haoyann <10...@qq.com>
AuthorDate: Wed Jun 30 09:57:59 2021 +0800

    fix subscribe service will block admin startup (#779)
---
 .../java/org/apache/dubbo/admin/service/RegistryServerSync.java  | 9 +++++----
 .../org/apache/dubbo/admin/service/RegistryServerSyncTest.java   | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
index 6a91f5c..f57cdb3 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
@@ -27,8 +27,9 @@ import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.registry.NotifyListener;
 import org.apache.dubbo.registry.Registry;
 import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
@@ -41,7 +42,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicLong;
 
 @Component
-public class RegistryServerSync implements InitializingBean, DisposableBean, NotifyListener {
+public class RegistryServerSync implements DisposableBean, NotifyListener {
 
     private static final Logger logger = LoggerFactory.getLogger(RegistryServerSync.class);
 
@@ -76,8 +77,8 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not
         return registryCache;
     }
 
-    @Override
-    public void afterPropertiesSet() throws Exception {
+    @EventListener(classes = ApplicationReadyEvent.class)
+    public void startSubscribe() {
         logger.info("Init Dubbo Admin Sync Cache...");
         registry.subscribe(SUBSCRIBE, this);
     }
diff --git a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
index ad1d631..a8ecc7c 100644
--- a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
+++ b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
@@ -53,7 +53,7 @@ public class RegistryServerSyncTest {
 
     @Test
     public void testAfterPropertiesSet() throws Exception {
-        registryServerSync.afterPropertiesSet();
+        registryServerSync.startSubscribe();
         verify(registry).subscribe(any(URL.class), any(RegistryServerSync.class));
     }