You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/12 12:35:23 UTC
[dubbo] branch master updated: fix destroy NullPointerException and
doOverrideIfNecessary (#8683)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new e63a7be fix destroy NullPointerException and doOverrideIfNecessary (#8683)
e63a7be is described below
commit e63a7bebf5bd50fd66699e6594b4dd31b3324166
Author: zrlw <zr...@sina.com>
AuthorDate: Sun Sep 12 20:35:10 2021 +0800
fix destroy NullPointerException and doOverrideIfNecessary (#8683)
IllegalStateException
---
.../main/java/org/apache/dubbo/rpc/model/ApplicationModel.java | 10 ++++++++++
.../apache/dubbo/registry/integration/RegistryProtocol.java | 10 ++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
index 4038146..1c41502 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
@@ -25,6 +25,7 @@ import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.context.ConfigManager;
import java.util.Collection;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -112,6 +113,15 @@ public class ApplicationModel {
return application == null ? getName() : application;
}
+ @Deprecated
+ public static String tryGetApplication() {
+ if (application != null) {
+ return application;
+ }
+ Optional<ApplicationConfig> appCfgOptional = getConfigManager().getApplication();
+ return appCfgOptional.isPresent() ? appCfgOptional.get().getName() : null;
+ }
+
// Currently used by UT.
@Deprecated
public static void setApplication(String application) {
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 987aba7..1fe263c 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
@@ -572,8 +572,13 @@ public class RegistryProtocol implements Protocol {
}
bounds.clear();
+ String application = ApplicationModel.tryGetApplication();
+ if (application == null) {
+ // already removed
+ return;
+ }
ExtensionLoader.getExtensionLoader(GovernanceRuleRepository.class).getDefaultExtension()
- .removeListener(ApplicationModel.getApplication() + CONFIGURATORS_SUFFIX, providerConfigurationListener);
+ .removeListener(application + CONFIGURATORS_SUFFIX, providerConfigurationListener);
}
@Override
@@ -688,7 +693,8 @@ public class RegistryProtocol implements Protocol {
return;
}
//The current, may have been merged many times
- URL currentUrl = exporter.getInvoker().getUrl();
+ Invoker<?> exporterInvoker = exporter.getInvoker();
+ URL currentUrl = exporterInvoker == null ? null : exporterInvoker.getUrl();
//Merged with this configuration
URL newUrl = getConfiguredInvokerUrl(configurators, originUrl);
newUrl = getConfiguredInvokerUrl(providerConfigurationListener.getConfigurators(), newUrl);