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

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


The following commit(s) were added to refs/heads/3.2 by this push:
     new c373ce10fe Added scheduler closure check during RegistryNotifier 
notify. (#13273)
c373ce10fe is described below

commit c373ce10fe92347423b397e7ebb91ab9ab0b9018
Author: 阿魁 <[email protected]>
AuthorDate: Mon Nov 6 16:46:04 2023 +0800

    Added scheduler closure check during RegistryNotifier notify. (#13273)
    
    * Added scheduler closure check during RegistryNotifier notify.
    
    * Added logs.
    
    * Updated logs.
    
    * Updated logs.
    
    * Updated logs.
    
    * Add URL.
---
 .../java/org/apache/dubbo/registry/RegistryNotifier.java     | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/RegistryNotifier.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/RegistryNotifier.java
index fe9296b8e3..ae60b913fa 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/RegistryNotifier.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/RegistryNotifier.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import static 
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_DELAY_EXECUTE_TIMES;
+import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_NOTIFY_EVENT;
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_NOTIFY_EVENT;
 
 public abstract class RegistryNotifier {
@@ -34,7 +35,7 @@ public abstract class RegistryNotifier {
     private static final ErrorTypeAwareLogger logger = 
LoggerFactory.getErrorTypeAwareLogger(RegistryNotifier.class);
     private volatile long lastExecuteTime;
     private volatile long lastEventTime;
-
+    private final URL url;
     private Object rawAddresses;
     private long delayTime;
 
@@ -50,6 +51,7 @@ public abstract class RegistryNotifier {
     }
 
     public RegistryNotifier(URL registryUrl, long delayTime, 
ScheduledExecutorService scheduler) {
+        this.url = registryUrl;
         this.delayTime = delayTime;
         if (scheduler == null) {
             this.scheduler = 
registryUrl.getOrDefaultFrameworkModel().getBeanFactory()
@@ -68,7 +70,13 @@ public abstract class RegistryNotifier {
 
         // more than 10 calls && next execute time is in the future
         boolean delay = shouldDelay.get() && delta < 0;
-        if (delay) {
+        // when the scheduler is shutdown, no notification is sent
+        if (scheduler.isShutdown()) {
+            if (logger.isWarnEnabled()) {
+                logger.warn(COMMON_FAILED_NOTIFY_EVENT, "", "", "Notification 
scheduler is off, no notifications are sent. Registry URL:  " + url);
+            }
+            return;
+        } else if (delay) {
             scheduler.schedule(new NotificationTask(this, notifyTime), -delta, 
TimeUnit.MILLISECONDS);
         } else {
             // check if more than 10 calls

Reply via email to