[ApiModel] Ensure thread safe access to ambiguous cache

Bug: b/231851850
Change-Id: Idcb89272807037685ff0b865bb06135699db9d04
diff --git a/src/main/java/com/android/tools/r8/androidapi/AndroidApiLevelHashingDatabaseImpl.java b/src/main/java/com/android/tools/r8/androidapi/AndroidApiLevelHashingDatabaseImpl.java
index f5343da..88c34b3 100644
--- a/src/main/java/com/android/tools/r8/androidapi/AndroidApiLevelHashingDatabaseImpl.java
+++ b/src/main/java/com/android/tools/r8/androidapi/AndroidApiLevelHashingDatabaseImpl.java
@@ -24,9 +24,9 @@
 import java.io.ObjectInputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
-import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 public class AndroidApiLevelHashingDatabaseImpl implements AndroidApiLevelDatabase {
@@ -38,7 +38,7 @@
   private final Int2ReferenceMap<AndroidApiLevel> lookupNonAmbiguousCache =
       new Int2ReferenceOpenHashMap<AndroidApiLevel>();
   private final Map<String, AndroidApiLevel> ambiguousHashesWithApiLevel = new HashMap<>();
-  private final Map<DexReference, AndroidApiLevel> ambiguousCache = new IdentityHashMap<>();
+  private final Map<DexReference, AndroidApiLevel> ambiguousCache = new ConcurrentHashMap<>();
 
   public AndroidApiLevelHashingDatabaseImpl(
       List<AndroidApiForHashingReference> predefinedApiTypeLookup) {