Skip to content

Commit

Permalink
Fix NPE when removing registry (#11514)
Browse files Browse the repository at this point in the history
Co-authored-by: zhujy <zhujy@pingpongx.com>
  • Loading branch information
haoxz11 and haoxz11 committed Feb 10, 2023
1 parent bc55100 commit 1ab11d3
Showing 1 changed file with 16 additions and 14 deletions.
Expand Up @@ -909,23 +909,25 @@ public void unexport() {
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) {
Expand Down

0 comments on commit 1ab11d3

Please sign in to comment.