void (MyKey realKey) { reentrancyCount++; List<Map.Entry<MyKey, StackFrame>> stack = new ArrayList<>(progressMap.entrySet()); int loopStart = ContainerUtil.indexOf(stack, entry -> entry.getKey().equals(realKey)); if (loopStart >= 0) { MyKey loopStartKey = stack.get(loopStart).getKey(); if (!preventions.containsKey(loopStartKey)) { preventions.put(loopStartKey, ourAssertOnMissedCache.get() ? new StackOverflowPreventedException(null) : null); } for (int i = loopStart + 1; i < stack.size(); i++) { stack.get(i).getValue().addPrevention(reentrancyCount, loopStartKey); } if (LOG.isDebugEnabled() && loopStart < stack.size() - 1) { LOG.debug("Recursion prevented for " + realKey + ", caching disabled for " + ContainerUtil.map(stack.subList(loopStart, stack.size()), Map.Entry::getKey)); } if (firstLoopStart > loopStart) { firstLoopStart = loopStart; intermediateCache.clear(); } } }