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 2022/07/01 06:17:32 UTC
[dubbo] branch 3.0 updated: [ISSUES #10249]Fix the problem of repeatedly creating registry in AbstractRegistryFactory#getRegistry #10249 (#10252)
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 <38...@users.noreply.github.com>
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 <ha...@ly.com>
---
.../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;
}