You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2021/11/25 06:20:01 UTC

[dubbo] 15/45: improve:优化多个注册中心时,检查 available 时消耗过多内存的问题

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch release/3.0.14-rpccontext-bugfix
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 9aae119f5a9f003866249d68c4a780aa672a38cf
Author: 未宇 <li...@alibaba-inc.com>
AuthorDate: Thu Oct 22 15:04:37 2020 +0800

    improve:优化多个注册中心时,检查 available 时消耗过多内存的问题
---
 .../apache/dubbo/registry/integration/RegistryDirectory.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

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 a4ac7a9..09b45b3 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
@@ -573,7 +573,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
         if (deleted != null) {
             for (URL url : deleted) {
                 if (url != null) {
-                    Invoker<T> invoker = oldUrlInvokerMap.remove(url);
+                    Invoker<T> invoker = oldUrlInvokerMap.get(url);
                     if (invoker != null) {
                         try {
                             invoker.destroy();
@@ -650,10 +650,14 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
         }
         Map<URL, Invoker<T>> localUrlInvokerMap = urlInvokerMap;
         if (localUrlInvokerMap != null && localUrlInvokerMap.size() > 0) {
-            for (Invoker<T> invoker : new ArrayList<>(localUrlInvokerMap.values())) {
-                if (invoker.isAvailable()) {
-                    return true;
+            try {
+                for (Map.Entry<URL,Invoker<T>> entry : localUrlInvokerMap.entrySet()){
+                    if (entry.getValue().isAvailable()) {
+                        return true;
+                    }
                 }
+            }catch (Throwable throwable){
+                return true;
             }
         }
         return false;