You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "leeyiyu (via GitHub)" <gi...@apache.org> on 2023/06/09 07:05:01 UTC

[GitHub] [rocketmq] leeyiyu opened a new pull request, #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

leeyiyu opened a new pull request, #6883:
URL: https://github.com/apache/rocketmq/pull/6883

   <!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   <!-- Please ensure that the related issue has already been created, and [link this pull request to that issue using keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>) to ensure automatic closure. -->
   
   Fixes #issue_id
   
   ### Brief Description
   
   
   <!-- Write a brief description for your pull request to help the maintainer understand the reasons behind your changes. -->
   
   ### How Did You Test This Change?
   
   
   ```
   @Test
       public void computeIfAbsent() {
   
           ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
   //        map.computeIfAbsent("AaAa", key->map.computeIfAbsent("BBBB",key2->"42"));
           ConcurrentHashMapUtils.computeIfAbsent(map, "AaAa", key -> map.computeIfAbsent("BBBB", key2 -> "42"));
       }
   
   ```
   
   <!-- In order to ensure the code quality of Apache RocketMQ, we expect every pull request to have undergone thorough testing. -->
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] ferrirW commented on pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "ferrirW (via GitHub)" <gi...@apache.org>.
ferrirW commented on PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#issuecomment-1591171105

   > check this ,https://juejin.cn/post/7094561581631012878
   > 
   > IMO, The original code has no problem.
   
   It doesn't seem to be same bug. The blog mentions is https://bugs.openjdk.org/browse/JDK-8161372
   
   I think @leeyiyu fixed is: https://bugs.openjdk.org/browse/JDK-8062841


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] ferrirW commented on a diff in pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "ferrirW (via GitHub)" <gi...@apache.org>.
ferrirW commented on code in PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#discussion_r1229589721


##########
common/src/main/java/org/apache/rocketmq/common/utils/ConcurrentHashMapUtils.java:
##########
@@ -40,10 +41,23 @@ public abstract class ConcurrentHashMapUtils {
      * @see <a href="https://bugs.openjdk.java.net/browse/JDK-8161372">https://bugs.openjdk.java.net/browse/JDK-8161372</a>
      */
     public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Function<? super K, ? extends V> func) {
+        Objects.requireNonNull(func);
         if (isJdk8) {
             V v = map.get(key);
             if (null == v) {
-                v = map.computeIfAbsent(key, func);
+//                v = map.computeIfAbsent(key, func);

Review Comment:
   Comments can be removed



-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] Codeprh commented on pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "Codeprh (via GitHub)" <gi...@apache.org>.
Codeprh commented on PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#issuecomment-1584314595

   Reference dubbo link:https://github.com/apache/dubbo/pull/11987


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] xiaoyifang commented on pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "xiaoyifang (via GitHub)" <gi...@apache.org>.
xiaoyifang commented on PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#issuecomment-1584446339

   > ConcurrentHashMapUtils.computeIfAbsent(map, "AaAa", key -> map.computeIfAbsent("BBBB", key2 -> "42"));
   
   This has caused a deadlock.  I think This should left for the user to avoid .
   
   the above code is similar like 
   ```
   synchronized(obj){
       synchronized(obj){
              //logic
       }
   
   }
   ```  
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] yuz10 merged pull request #6883: [ISSUE #6879] ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "yuz10 (via GitHub)" <gi...@apache.org>.
yuz10 merged PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] leeyiyu commented on pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "leeyiyu (via GitHub)" <gi...@apache.org>.
leeyiyu commented on PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#issuecomment-1584298940

   > 
   
   
   
   > 
   
   
   
   > check this ,https://juejin.cn/post/7094561581631012878
   > 
   > IMO, The original code has no problem.
   
   You can run this Case,CPU utilization will be 100%
   
   ```
   @Test
       public void computeIfAbsent() {
   
           ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
           ConcurrentHashMapUtils.computeIfAbsent(map, "AaAa", key -> map.computeIfAbsent("BBBB", key2 -> "42"));
       }
   ```


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq] xiaoyifang commented on pull request #6883: ConcurrentHashMapUtils fails to solve the loop bug in JDK8

Posted by "xiaoyifang (via GitHub)" <gi...@apache.org>.
xiaoyifang commented on PR #6883:
URL: https://github.com/apache/rocketmq/pull/6883#issuecomment-1584276052

   check this ,https://juejin.cn/post/7094561581631012878
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

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