Skip to content

Commit

Permalink
CLDR-17504 fix recursive update in XPathParts (unicode-org#3631)
Browse files Browse the repository at this point in the history
Co-authored-by: David Beaumont <[email protected]>
  • Loading branch information
srl295 and hagbard authored Apr 13, 2024
1 parent b7c1b01 commit b5fcd00
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 b5fcd00

Please sign in to comment.