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/10/13 07:53:55 UTC
[dubbo] branch 3.0 updated: [3.0] check applicationModel destroy
state at blockUntilUpdated (#9001)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 73f7da1 [3.0] check applicationModel destroy state at blockUntilUpdated (#9001)
73f7da1 is described below
commit 73f7da19f4df65f1ee83827e5e98e83816233bfb
Author: zrlw <zr...@sina.com>
AuthorDate: Wed Oct 13 15:53:37 2021 +0800
[3.0] check applicationModel destroy state at blockUntilUpdated (#9001)
* check stopping state at blockUntilUpdated
* add applicationModel deployer null check
* cancel asyncMetadataFuture after destroy applicationModel
* add stopping state of ScopeModel
---
.../src/main/java/org/apache/dubbo/rpc/model/ScopeModel.java | 10 ++++++++++
.../apache/dubbo/config/deploy/DefaultApplicationDeployer.java | 1 +
.../client/metadata/store/InMemoryWritableMetadataService.java | 4 +++-
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModel.java b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModel.java
index a7bc5c5..1cc4712 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModel.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModel.java
@@ -69,6 +69,7 @@ public abstract class ScopeModel implements ExtensionAccessor {
private Map<String, Object> attributes;
private AtomicBoolean destroyed = new AtomicBoolean(false);
+ private volatile boolean stopping;
public ScopeModel(ScopeModel parent, ExtensionScope scope) {
this.parent = parent;
@@ -91,6 +92,7 @@ public abstract class ScopeModel implements ExtensionAccessor {
this.destroyListeners = new LinkedList<>();
this.attributes = new ConcurrentHashMap<>();
this.classLoaders = new ConcurrentHashSet<>();
+ this.stopping = false;
// Add Framework's ClassLoader by default
ClassLoader dubboClassLoader = ScopeModel.class.getClassLoader();
@@ -117,6 +119,14 @@ public abstract class ScopeModel implements ExtensionAccessor {
return destroyed.get();
}
+ public void setStopping() {
+ stopping = true;
+ }
+
+ public boolean isStopping() {
+ return stopping;
+ }
+
protected void notifyDestroy() {
for (ScopeModelDestroyListener destroyListener : destroyListeners) {
destroyListener.onDestroy(this);
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
index 7da8db5..61ac94a 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
@@ -865,6 +865,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
}
private void onStopping() {
+ applicationModel.setStopping();
setStopping();
if (logger.isInfoEnabled()) {
logger.info(getIdentifier() + " is stopping.");
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/InMemoryWritableMetadataService.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/InMemoryWritableMetadataService.java
index 1018f33..30ec1ed 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/InMemoryWritableMetadataService.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/InMemoryWritableMetadataService.java
@@ -324,7 +324,9 @@ public class InMemoryWritableMetadataService implements WritableMetadataService,
metadataSemaphore.drainPermits();
updateLock.writeLock().lock();
} catch (InterruptedException e) {
- logger.warn("metadata refresh thread has been interrupted unexpectedly while waiting for update.", e);
+ if (!applicationModel.isStopping()) {
+ logger.warn("metadata refresh thread has been interrupted unexpectedly while waiting for update.", e);
+ }
}
}