Recursive ConcurrentHashMap.computeIfAbsent() call never terminates. Bug or “feature”?

前端 未结 3 896
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 05:51

Some time ago, I\'ve blogged about a Java 8 functional way of calculating fibonacci numbers recursively, with a ConcurrentHashMap cache and the new, useful

3条回答
  •  攒了一身酷
    2020-11-28 06:10

    This is fixed in JDK-8062841.

    In the 2011 proposal, I identified this issue during the code review. The JavaDoc was updated and a temporary fix was added. It was removed in a further rewrite due to performance issues.

    In the 2014 discussion, we explored ways to better detect and fail. Note that some of the discussion was taken offline to private email for considering the low-level changes. While not every case can be covered, the common cases will not livelock. These fixes are in Doug's repository but have not made it into a JDK release.

提交回复
热议问题