You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "CrazyHZM (via GitHub)" <gi...@apache.org> on 2023/05/06 03:25:31 UTC

[GitHub] [dubbo] CrazyHZM commented on a diff in pull request #11987: fix #11986 ConcurrentHashMapUtils lock bug

CrazyHZM commented on code in PR #11987:
URL: https://github.com/apache/dubbo/pull/11987#discussion_r1186609886


##########
dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConcurrentHashMapUtils.java:
##########
@@ -35,7 +35,18 @@ public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Function<
         if (JRE.JAVA_8.isCurrentVersion()) {
             V v = map.get(key);
             if (null == v) {
-                v = map.computeIfAbsent(key, func);
+                // issue#11986 lock bug
+                // v = map.computeIfAbsent(key, func);
+
+                // this bug fix methods maybe cause `func.apply` multiple calls.
+                v = func.apply(key);

Review Comment:
   Please check whether v is null.



-- 
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