Tag

computeIfAbsent

0 views collected around this technical thread.

Cognitive Technology Team
Cognitive Technology Team
Jun 10, 2024 · Backend Development

Recursive Update Bug in ConcurrentHashMap.computeIfAbsent Causing Infinite Loop and CPU Spike

The article explains a bug in Java's ConcurrentHashMap.computeIfAbsent that can cause recursive updates and infinite loops, leading to CPU spikes, and shows that newer Java versions throw an IllegalStateException while recommending avoiding nested computeIfAbsent/putIfAbsent calls, with a code example.

ConcurrentHashMapJavabackend
0 likes · 3 min read
Recursive Update Bug in ConcurrentHashMap.computeIfAbsent Causing Infinite Loop and CPU Spike
macrozheng
macrozheng
Aug 13, 2020 · Backend Development

Why JDK 8’s computeIfAbsent Can Deadlock: A Deep Dive into the Bug

This article explores a JDK 8 bug in ConcurrentHashMap’s computeIfAbsent method that can cause an infinite loop, explains how the issue was discovered, reproduces it with test code, analyzes the root cause, and shows the fix introduced in JDK 9.

ConcurrentHashMapJDKJava8
0 likes · 16 min read
Why JDK 8’s computeIfAbsent Can Deadlock: A Deep Dive into the Bug