diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java index 6cad7f5e3ff..3f1b030e48f 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java @@ -1211,10 +1211,13 @@ public XPathParts cloneAsThawed() { } public static XPathParts getFrozenInstance(String path) { - XPathParts result = - cache.computeIfAbsent( - path, - (String forPath) -> new XPathParts().addInternal(forPath, true).freeze()); + XPathParts result = cache.get(path); + if (result == null) { + // CLDR-17504: This can recursively create new paths during creation so MUST NOT + // happen inside the lambda of computeIfAbsent(), but freezing the path is safe. + XPathParts unfrozen = new XPathParts().addInternal(path, true); + result = cache.computeIfAbsent(path, (String p) -> unfrozen.freeze()); + } return result; }