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 aebeee1844 [ISSUES #10249]Fix the problem of repeatedly creating 
registry in AbstractRegistryFactory#getRegistry #10249 (#10252)
aebeee1844 is described below

commit aebeee1844e1093192472419bb76b0de4ee2711b
Author: xh1202 <[email protected]>
AuthorDate: Fri Jul 1 14:17:25 2022 +0800

    [ISSUES #10249]Fix the problem of repeatedly creating registry in 
AbstractRegistryFactory#getRegistry #10249 (#10252)
    
    Co-authored-by: xuhao <[email protected]>
---
 .../dubbo/registry/support/AbstractRegistryFactory.java    | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java
index f1afd1eb41..3933c2c148 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java
@@ -87,6 +87,13 @@ public abstract class AbstractRegistryFactory implements 
RegistryFactory, ScopeM
             }
             //create registry by spi/ioc
             registry = createRegistry(url);
+            if (check && registry == null) {
+                throw new IllegalStateException("Can not create registry " + 
url);
+            }
+
+            if (registry != null) {
+                registryManager.putRegistry(key, registry);
+            }
         } catch (Exception e) {
             if (check) {
                 throw new RuntimeException("Can not create registry " + url, 
e);
@@ -98,13 +105,6 @@ public abstract class AbstractRegistryFactory implements 
RegistryFactory, ScopeM
             registryManager.getRegistryLock().unlock();
         }
 
-        if (check && registry == null) {
-            throw new IllegalStateException("Can not create registry " + url);
-        }
-
-        if (registry != null) {
-            registryManager.putRegistry(key, registry);
-        }
         return registry;
     }
 

Reply via email to