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

zhangzicheng 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 b7e0abb76 [ISSUE #4157] Prevent the first time from failing to load 
(#4161)
b7e0abb76 is described below

commit b7e0abb76082b3f535cdbd721849334b80536f5a
Author: wzhangNJ <[email protected]>
AuthorDate: Mon Nov 7 16:29:08 2022 +0800

    [ISSUE #4157] Prevent the first time from failing to load (#4161)
    
    Co-authored-by: 张文 <[email protected]>
---
 .../client/core/client/AbstractContextRefreshedEventListener.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java
 
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java
index 0bd49bf0e..80b74a393 100644
--- 
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java
+++ 
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java
@@ -98,14 +98,14 @@ public abstract class 
AbstractContextRefreshedEventListener<T, A extends Annotat
     
     @Override
     public void onApplicationEvent(@NonNull final ContextRefreshedEvent event) 
{
-        if (!registered.compareAndSet(false, true)) {
-            return;
-        }
         final ApplicationContext context = event.getApplicationContext();
         Map<String, T> beans = getBeans(context);
         if (MapUtils.isEmpty(beans)) {
             return;
         }
+        if (!registered.compareAndSet(false, true)) {
+            return;
+        }
         publisher.publishEvent(buildURIRegisterDTO(context, beans));
         beans.forEach(this::handle);
     }

Reply via email to