From 70660cb9697fac3c48bcfad0f80dff7d09dbc05c Mon Sep 17 00:00:00 2001 From: pandaapo <35672972+pandaapo@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:08:03 +0800 Subject: [PATCH] fix issue: unexport() throws NPE when register fail. (#10893) --- .../apache/dubbo/registry/integration/RegistryProtocol.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 6a8449eac2..a993d8e35d 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 @@ -72,6 +72,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN; import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; +import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT; import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY; import static org.apache.dubbo.common.constants.CommonConstants.EXTRA_KEYS_KEY; @@ -919,7 +920,10 @@ public class RegistryProtocol implements Protocol, ScopeModelAware { } //TODO wait for shutdown timeout is a bit strange - int timeout = ConfigurationUtils.getServerShutdownTimeout(subscribeUrl.getScopeModel()); + int timeout = DEFAULT_SERVER_SHUTDOWN_TIMEOUT; + if (subscribeUrl != null) { + timeout = ConfigurationUtils.getServerShutdownTimeout(subscribeUrl.getScopeModel()); + } executor.schedule(() -> { try { exporter.unexport();