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/04/21 12:22:55 UTC

[dubbo] branch master updated: Use double-check to get elements from the cache (#7583)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 7677eb3  Use double-check to get elements from the cache (#7583)
7677eb3 is described below

commit 7677eb3f8683517b6d31776c5042792b273335be
Author: 灼华 <43...@users.noreply.github.com>
AuthorDate: Wed Apr 21 20:22:15 2021 +0800

    Use double-check to get elements from the cache (#7583)
---
 .../metadata/report/support/AbstractMetadataReportFactory.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactory.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactory.java
index 9776e8c..f2867d7 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactory.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactory.java
@@ -39,10 +39,16 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
         url = url.setPath(MetadataReport.class.getName())
                 .removeParameters(EXPORT_KEY, REFER_KEY);
         String key = url.toServiceString();
+
+        MetadataReport metadataReport = SERVICE_STORE_MAP.get(key);
+        if (metadataReport != null) {
+            return metadataReport;
+        }
+
         // Lock the metadata access process to ensure a single instance of the metadata instance
         LOCK.lock();
         try {
-            MetadataReport metadataReport = SERVICE_STORE_MAP.get(key);
+            metadataReport = SERVICE_STORE_MAP.get(key);
             if (metadataReport != null) {
                 return metadataReport;
             }