Skip to content

Commit

Permalink
Remove duplicated invokers in registry notification
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Jan 16, 2025
1 parent ef7e02f commit 5a38663
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ private void refreshInvoker(List<URL> invokerUrls) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ private void refreshInvoker(List<URL> invokerUrls) {
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;
Expand Down

0 comments on commit 5a38663

Please sign in to comment.