Skip to content

Commit

Permalink
CLDR-17504 fix recursive update in XPathParts (#3631)
Browse files Browse the repository at this point in the history
Co-authored-by: David Beaumont <[email protected]>
(cherry picked from commit b5fcd00)
  • Loading branch information
srl295 authored and pedberg-icu committed Apr 22, 2024
1 parent 16ac4a9 commit 60a4d46
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 60a4d46

Please sign in to comment.