You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/01 03:38:07 UTC

[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #10229: refactor: optimize ExtensionLoader code style

AlbumenJ commented on code in PR #10229:
URL: https://github.com/apache/dubbo/pull/10229#discussion_r911589676


##########
dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java:
##########
@@ -436,18 +425,7 @@ public T getExtension(String name, boolean wrap) {
         if ("true".equals(name)) {
             return getDefaultExtension();
         }
-        final Holder<Object> holder = getOrCreateHolder(name);
-        Object instance = holder.get();
-        if (instance == null) {
-            synchronized (holder) {
-                instance = holder.get();
-                if (instance == null) {
-                    instance = createExtension(name, wrap);
-                    holder.set(instance);
-                }
-            }
-        }
-        return (T) instance;
+        return cachedInstances.computeIfAbsent(name, (k) -> createExtension(k, wrap));

Review Comment:
   but lambda might create a lot of class object, and will lead to metadata space increase



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org