Code Room
Code reviewHardcr-g019
Subject AtomicityLevel Senior–Staff~26 minCommon in Concurrency · Algorithms & data structures interviewsIndustries Software development

Question

Review this Java memoizing cache built on ConcurrentHashMap.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
private final ConcurrentHashMap<Key, Value> cache = new ConcurrentHashMap<>(); public Value get(Key k) {    if (cache.containsKey(k)) {        return cache.get(k);    }    Value v = expensiveCompute(k);    cache.put(k, v);    return v;}
Run or narrate your approach, then ask the coach.