You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hy...@apache.org on 2020/03/21 14:25:38 UTC

[dubbo] branch master updated: [Dubbo-5592] simplify code for getExtensionLoader method (#5593)

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

hyunkun 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 7a73b3f  [Dubbo-5592] simplify code for getExtensionLoader method (#5593)
7a73b3f is described below

commit 7a73b3f86a0fbf75f7c190b813dace642bd4a9c7
Author: huangdx0726 <lo...@foxmail.com>
AuthorDate: Sat Mar 21 22:25:22 2020 +0800

    [Dubbo-5592] simplify code for getExtensionLoader method (#5593)
---
 .../java/org/apache/dubbo/common/extension/ExtensionLoader.java   | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
index b53729e..708c222 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
@@ -141,13 +141,7 @@ public class ExtensionLoader<T> {
             throw new IllegalArgumentException("Extension type (" + type +
                     ") is not an extension, because it is NOT annotated with @" + SPI.class.getSimpleName() + "!");
         }
-
-        ExtensionLoader<T> loader = (ExtensionLoader<T>) EXTENSION_LOADERS.get(type);
-        if (loader == null) {
-            EXTENSION_LOADERS.putIfAbsent(type, new ExtensionLoader<T>(type));
-            loader = (ExtensionLoader<T>) EXTENSION_LOADERS.get(type);
-        }
-        return loader;
+        return (ExtensionLoader<T>) EXTENSION_LOADERS.computeIfAbsent(type, k -> new ExtensionLoader<T>(type));
     }
 
     // For testing purposes only