Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] fix destroy IllegalStateException and doOverrideIfNecessary NPE #8683

Merged
merged 1 commit into from Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,6 +25,7 @@
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;

Expand Down Expand Up @@ -112,6 +113,15 @@ public static String getApplication() {
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) {
Expand Down
Expand Up @@ -572,8 +572,13 @@ public void destroy() {
}
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
Expand Down Expand Up @@ -688,7 +693,8 @@ public synchronized void doOverrideIfNecessary() {
return;
}
//The current, may have been merged many times
URL currentUrl = exporter.getInvoker().getUrl();
Invoker<?> exporterInvoker = exporter.getInvoker();
AlbumenJ marked this conversation as resolved.
Show resolved Hide resolved
URL currentUrl = exporterInvoker == null ? null : exporterInvoker.getUrl();
//Merged with this configuration
URL newUrl = getConfiguredInvokerUrl(configurators, originUrl);
newUrl = getConfiguredInvokerUrl(providerConfigurationListener.getConfigurators(), newUrl);
Expand Down