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

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


The following commit(s) were added to refs/heads/3.1 by this push:
     new 1ab11d34bf Fix NPE when removing registry (#11514)
1ab11d34bf is described below

commit 1ab11d34bff5cf3a977deebb7641f7d02a7570f0
Author: haoxz11 <[email protected]>
AuthorDate: Fri Feb 10 15:50:49 2023 +0800

    Fix NPE when removing registry (#11514)
    
    Co-authored-by: zhujy <[email protected]>
---
 .../registry/integration/RegistryProtocol.java     | 30 ++++++++++++----------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index b038d9b34b..02e75993a4 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -909,23 +909,25 @@ public class RegistryProtocol implements Protocol, 
ScopeModelAware {
                 if (subscribeUrl != null) {
                     Map<URL, Set<NotifyListener>> overrideListeners = 
getProviderConfigurationListener(subscribeUrl).getOverrideListeners();
                     Set<NotifyListener> listeners = 
overrideListeners.get(subscribeUrl);
-                    if (listeners.remove(notifyListener)) {
-                        if (!registry.isServiceDiscovery()) {
-                            registry.unsubscribe(subscribeUrl, notifyListener);
-                        }
-                        ApplicationModel applicationModel = 
getApplicationModel(registerUrl.getScopeModel());
-                        if 
(applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class,
 ENABLE_CONFIGURATION_LISTEN, true)) {
-                            for (ModuleModel moduleModel : 
applicationModel.getPubModuleModels()) {
-                                if 
(moduleModel.getServiceRepository().getExportedServices().size() > 0) {
-                                    
moduleModel.getExtensionLoader(GovernanceRuleRepository.class).getDefaultExtension()
-                                        
.removeListener(subscribeUrl.getServiceKey() + CONFIGURATORS_SUFFIX,
-                                            
serviceConfigurationListeners.remove(subscribeUrl.getServiceKey()));
+                    if(listeners != null){
+                        if (listeners.remove(notifyListener)) {
+                            if (!registry.isServiceDiscovery()) {
+                                registry.unsubscribe(subscribeUrl, 
notifyListener);
+                            }
+                            ApplicationModel applicationModel = 
getApplicationModel(registerUrl.getScopeModel());
+                            if 
(applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class,
 ENABLE_CONFIGURATION_LISTEN, true)) {
+                                for (ModuleModel moduleModel : 
applicationModel.getPubModuleModels()) {
+                                    if 
(moduleModel.getServiceRepository().getExportedServices().size() > 0) {
+                                        
moduleModel.getExtensionLoader(GovernanceRuleRepository.class).getDefaultExtension()
+                                            
.removeListener(subscribeUrl.getServiceKey() + CONFIGURATORS_SUFFIX,
+                                                
serviceConfigurationListeners.remove(subscribeUrl.getServiceKey()));
+                                    }
                                 }
                             }
                         }
-                    }
-                    if (listeners.isEmpty()) {
-                        overrideListeners.remove(subscribeUrl);
+                        if (listeners.isEmpty()) {
+                            overrideListeners.remove(subscribeUrl);
+                        }
                     }
                 }
             } catch (Throwable t) {

Reply via email to