Refactor getRegistry: firstly get registry outside from lock#5484
Refactor getRegistry: firstly get registry outside from lock#5484maoyiz wants to merge 1 commit intoapache:masterfrom maoyiz:refactor-getRegistry
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5484 +/- ##
============================================
- Coverage 61.08% 61.01% -0.07%
+ Complexity 422 421 -1
============================================
Files 919 919
Lines 37502 37502
Branches 5444 5444
============================================
- Hits 22909 22883 -26
- Misses 12097 12124 +27
+ Partials 2496 2495 -1
Continue to review full report at Codecov.
|
|
ping @zhaixiaoxiang |
| .removeParameters(EXPORT_KEY, REFER_KEY) | ||
| .build(); | ||
| String key = url.toServiceStringWithoutResolving(); | ||
| Registry registry = REGISTRIES.get(key); |
There was a problem hiding this comment.
i think shouldn't move those code outside the lock-unlock block. it will cause invoke createRegistry multiple times in some cases.
| if (registry == null) { | ||
| throw new IllegalStateException("Can not create registry " + url); | ||
| } | ||
| REGISTRIES.put(key, registry); |
There was a problem hiding this comment.
Maybe using the java.util.concurrent.ConcurrentHashMap#computeIfAbsent is the better choice ?
There was a problem hiding this comment.
Agree. Could you please take a look? @zhaixiaoxiang
| if (registry == null) { | ||
| throw new IllegalStateException("Can not create registry " + url); | ||
| } | ||
| REGISTRIES.put(key, registry); |
There was a problem hiding this comment.
Agree. Could you please take a look? @zhaixiaoxiang
|
Closed. |
What is the purpose of the change
we should get registry instance outside lock firstly, and if not null, return directly.
Brief changelog
AbstractRegistryFactory.java
Verifying this change
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false&mvn clean test-compile failsafe:integration-testto make sure unit-test and integration-test pass.