This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new a35af2742a Remove duplicated invokers in registry notification (#15060)
a35af2742a is described below
commit a35af2742a13cd7169d3b80dc6ec0bba2c40da9f
Author: Albumen Kevin <[email protected]>
AuthorDate: Fri May 16 16:47:58 2025 +0800
Remove duplicated invokers in registry notification (#15060)
---
.../registry/client/ServiceDiscoveryRegistryDirectory.java | 11 +++++++++++
.../apache/dubbo/registry/integration/RegistryDirectory.java | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java
index b743a1c30e..e4297c0991 100644
---
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java
+++
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java
@@ -340,6 +340,17 @@ public class ServiceDiscoveryRegistryDirectory<T> extends
DynamicDirectory<T> {
return;
}
+ int originSize = invokerUrls.size();
+ invokerUrls =
invokerUrls.stream().distinct().collect(Collectors.toList());
+ if (invokerUrls.size() != originSize) {
+ logger.info("Received duplicated invoker urls changed event
from registry. "
+ + "Registry type: instance. "
+ + "Service Key: "
+ + getConsumerUrl().getServiceKey() + ". "
+ + "Notify Urls Size : " + originSize + ". "
+ + "Distinct Urls Size: " + invokerUrls.size() + ".");
+ }
+
// use local reference to avoid NPE as this.urlInvokerMap will be
set null concurrently at
// destroyAllInvokers().
Map<ProtocolServiceKeyWithAddress, Invoker<T>> localUrlInvokerMap
= this.urlInvokerMap;
diff --git
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
index 1eaf26c2c9..09297434ef 100644
---
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
+++
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
@@ -305,6 +305,17 @@ public class RegistryDirectory<T> extends
DynamicDirectory<T> {
return;
}
+ int originSize = invokerUrls.size();
+ invokerUrls =
invokerUrls.stream().distinct().collect(Collectors.toList());
+ if (invokerUrls.size() != originSize) {
+ logger.info("Received duplicated invoker urls changed event
from registry. "
+ + "Registry type: interface. "
+ + "Service Key: "
+ + getConsumerUrl().getServiceKey() + ". "
+ + "Notify Urls Size : " + originSize + ". "
+ + "Distinct Urls Size: " + invokerUrls.size() + ".");
+ }
+
// use local reference to avoid NPE as this.urlInvokerMap will be
set null concurrently at
// destroyAllInvokers().
Map<URL, Invoker<T>> localUrlInvokerMap = this.urlInvokerMap;