mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
Fix non-thread-safe operations on canonical id cache
// FREEBIE
This commit is contained in:
parent
fd3d02d818
commit
edac0e85c7
@ -28,19 +28,14 @@ import android.telephony.PhoneNumberUtils;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.i18n.phonenumbers.NumberParseException;
|
|
||||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
|
||||||
import com.google.i18n.phonenumbers.Phonenumber;
|
|
||||||
import com.google.i18n.phonenumbers.ShortNumberInfo;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
import org.thoughtcrime.securesms.util.LRUCache;
|
import org.thoughtcrime.securesms.util.LRUCache;
|
||||||
import org.thoughtcrime.securesms.util.ShortCodeUtil;
|
import org.thoughtcrime.securesms.util.ShortCodeUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -64,9 +59,9 @@ public class CanonicalAddressDatabase {
|
|||||||
private DatabaseHelper databaseHelper;
|
private DatabaseHelper databaseHelper;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
private final Map<String, Long> addressCache = new ConcurrentHashMap<>();
|
private final Map<String, Long> addressCache = new ConcurrentHashMap<>();
|
||||||
private final Map<Long, String> idCache = new ConcurrentHashMap<>();
|
private final Map<Long, String> idCache = new ConcurrentHashMap<>();
|
||||||
private final LRUCache<String, String> formattedAddressCache = new LRUCache<>(100);
|
private final Map<String, String> formattedAddressCache = Collections.synchronizedMap(new LRUCache<String, String>(100));
|
||||||
|
|
||||||
public synchronized static CanonicalAddressDatabase getInstance(Context context) {
|
public synchronized static CanonicalAddressDatabase getInstance(Context context) {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user