Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a999425 authored by You Kim's avatar You Kim Committed by Gerrit Code Review
Browse files

Incorrect evictor key in TokenCache

mTokenEvictor uses a Pair<> of account type and token as a key.

Change-Id: Ia24eb6bdbf183d82e189a74624322e3ba71cbad7
parent a59bf9da
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ import java.util.Objects;
                 * This is recursive, but it won't spiral out of control because LruCache is
                 * thread safe and the Evictor can only be removed once.
                 */
                Evictor evictor = mTokenEvictors.remove(oldVal.token);
                Evictor evictor = mTokenEvictors.remove(new Pair<>(k.account.type, oldVal.token));
                if (evictor != null) {
                    evictor.evict();
                }
@@ -133,13 +133,15 @@ import java.util.Objects;
        }

        public void putToken(Key k, Value v) {
            // Prepare for removal by token string.
            Evictor tokenEvictor = mTokenEvictors.get(v.token);
            // Prepare for removal by pair of account type and token string.
            Pair<String, String> pair = new Pair<>(k.account.type, v.token);

            Evictor tokenEvictor = mTokenEvictors.get(pair);
            if (tokenEvictor == null) {
                tokenEvictor = new Evictor();
            }
            tokenEvictor.add(k);
            mTokenEvictors.put(new Pair<>(k.account.type, v.token), tokenEvictor);
            mTokenEvictors.put(pair, tokenEvictor);

            // Prepare for removal by associated account.
            Evictor accountEvictor = mAccountEvictors.get(k.account);