Skip to content

Commit

Permalink
CLDR-7646 TestCache concurrency issues
Browse files Browse the repository at this point in the history
- concurrencyLevel to 1
  • Loading branch information
srl295 committed Jan 11, 2024
1 parent a91f8e8 commit f6aa620
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tools/cldr-code/src/main/java/org/unicode/cldr/test/TestCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
Expand Down Expand Up @@ -62,11 +61,19 @@ public void check(String path, List<CheckStatus> result, String value) {
*/
result.clear();
Pair<String, String> key = new Pair<>(path, value);
List<CheckStatus> cachedResult = pathCache.computeIfAbsent(key, (Pair<String, String> k) -> {
List<CheckStatus> l = new ArrayList<CheckStatus>();
cc.check(k.getFirst(), file.getFullXPath(k.getFirst()), k.getSecond(), options, l);
return l;
});
List<CheckStatus> cachedResult =
pathCache.computeIfAbsent(
key,
(Pair<String, String> k) -> {
List<CheckStatus> l = new ArrayList<CheckStatus>();
cc.check(
k.getFirst(),
file.getFullXPath(k.getFirst()),
k.getSecond(),
options,
l);
return l;
});
if (cachedResult != null) {
result.addAll(cachedResult);
}
Expand All @@ -91,6 +98,7 @@ public List<CheckStatus> getPossibleProblems() {
private Cache<CheckCLDR.Options, TestResultBundle> testResultCache =
CacheBuilder.newBuilder()
.maximumSize(CLDRConfig.getInstance().getProperty("CLDR_TESTCACHE_SIZE", 12))
.concurrencyLevel(1)
.softValues()
.build();

Expand Down

0 comments on commit f6aa620

Please sign in to comment.