zonghaishang commented on a change in pull request #2566: Update 
AbstractRegistryFactory.java
URL: https://github.com/apache/incubator-dubbo/pull/2566#discussion_r221161341
 
 

 ##########
 File path: 
dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java
 ##########
 @@ -85,24 +85,31 @@ public Registry getRegistry(URL url) {
         url = url.setPath(RegistryService.class.getName())
                 .addParameter(Constants.INTERFACE_KEY, 
RegistryService.class.getName())
                 .removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
+        
         String key = url.toServiceString();
-        // Lock the registry access process to ensure a single instance of the 
registry
-        LOCK.lock();
-        try {
-            Registry registry = REGISTRIES.get(key);
-            if (registry != null) {
-                return registry;
-            }
-            registry = createRegistry(url);
-            if (registry == null) {
-                throw new IllegalStateException("Can not create registry " + 
url);
+        
+        Registry registry = REGISTRIES.get(key);
+
+        if (registry == null){
+
+            //阻塞创建相同的注册服务
+            synchronized (key){
 
 Review comment:
   Locking here is not correct.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to