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

albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 2a42f4f908 fix RegistryDirectory deadlock (#14454)
2a42f4f908 is described below

commit 2a42f4f90805ffcaa4425435a0b2b2d574a570ce
Author: Sean Yang <[email protected]>
AuthorDate: Sun Jul 21 14:27:26 2024 +0800

    fix RegistryDirectory deadlock (#14454)
---
 .../dubbo/registry/multicast/MulticastRegistry.java     | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
 
b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
index 6763543c7c..0ca952e6d8 100644
--- 
a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
+++ 
b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
@@ -91,14 +91,13 @@ public class MulticastRegistry extends FailbackRegistry {
 
     private final int cleanPeriod;
 
+    private final ApplicationModel applicationModel;
+
     private volatile boolean admin = false;
 
     public MulticastRegistry(URL url, ApplicationModel applicationModel) {
-        this(url);
-    }
-
-    public MulticastRegistry(URL url) {
         super(url);
+        this.applicationModel = applicationModel;
         if (url.isAnyHost()) {
             throw new IllegalStateException("registry address == null");
         }
@@ -121,7 +120,7 @@ public class MulticastRegistry extends FailbackRegistry {
                                 if (i > 0) {
                                     msg = msg.substring(0, i).trim();
                                 }
-                                MulticastRegistry.this.receive(msg, 
(InetSocketAddress) recv.getSocketAddress());
+                                receive(msg, (InetSocketAddress) 
recv.getSocketAddress());
                                 Arrays.fill(buf, (byte) 0);
                             } catch (Throwable e) {
                                 if (!multicastSocket.isClosed()) {
@@ -159,6 +158,10 @@ public class MulticastRegistry extends FailbackRegistry {
         }
     }
 
+    public MulticastRegistry(URL url) {
+        this(url, url.getOrDefaultApplicationModel());
+    }
+
     private void checkMulticastAddress(InetAddress multicastAddress) {
         if (!multicastAddress.isMulticastAddress()) {
             String message = "Invalid multicast address " + multicastAddress;
@@ -216,6 +219,10 @@ public class MulticastRegistry extends FailbackRegistry {
         if (logger.isInfoEnabled()) {
             logger.info("Receive multicast message: " + msg + " from " + 
remoteAddress);
         }
+        if (applicationModel.isDestroyed()) {
+            logger.info("The applicationModel is destroyed, skip");
+            return;
+        }
         if (msg.startsWith(REGISTER)) {
             URL url = URL.valueOf(msg.substring(REGISTER.length()).trim());
             registered(url);

Reply via email to