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/06/15 08:57:10 UTC

[dubbo] branch 3.0 updated: Fix concurrent modified problem (#8051)

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 b1da37a  Fix concurrent modified problem (#8051)
b1da37a is described below

commit b1da37a5873b19dc3d3f0ee25665e534b00513bc
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Tue Jun 15 16:56:52 2021 +0800

    Fix concurrent modified problem (#8051)
---
 .../org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
index 771e661..36f1990 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
@@ -37,13 +37,13 @@ import org.apache.dubbo.registry.support.FailbackRegistry;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 import static java.lang.String.format;
@@ -104,7 +104,7 @@ public class ServiceDiscoveryRegistry implements Registry {
     private final Set<String> registeredListeners = new LinkedHashSet<>();
 
     /* apps - listener */
-    private final Map<String, ServiceInstancesChangedListener> serviceListeners = new HashMap<>();
+    private final Map<String, ServiceInstancesChangedListener> serviceListeners = new ConcurrentHashMap<>();
 
     private URL registryURL;