From 77f4273c3a45bfc1044b71b8ca8cd5f0928710a4 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 13 Jan 2021 22:32:07 +0100 Subject: [PATCH] Remove caching from OpenPGP trust store --- .../abstr/AbstractOpenPgpTrustStore.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/abstr/AbstractOpenPgpTrustStore.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/abstr/AbstractOpenPgpTrustStore.java index fb9f40502..cedb34df0 100644 --- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/abstr/AbstractOpenPgpTrustStore.java +++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/abstr/AbstractOpenPgpTrustStore.java @@ -17,8 +17,6 @@ package org.jivesoftware.smackx.ox.store.abstr; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import org.jivesoftware.smackx.ox.store.definition.OpenPgpTrustStore; @@ -27,8 +25,6 @@ import org.pgpainless.key.OpenPgpV4Fingerprint; public abstract class AbstractOpenPgpTrustStore implements OpenPgpTrustStore { - private final Map> trustCache = new HashMap<>(); - /** * Read the trust record for the key with fingerprint {@code fingerprint} of user {@code owner} from local storage. * This method returns {@link Trust#undecided} in case that no trust record has been found. @@ -55,37 +51,14 @@ public abstract class AbstractOpenPgpTrustStore implements OpenPgpTrustStore { @Override public Trust getTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException { Trust trust; - Map trustMap = trustCache.get(owner); - - if (trustMap != null) { - trust = trustMap.get(fingerprint); - if (trust != null) { - return trust; - } - } else { - trustMap = new HashMap<>(); - trustCache.put(owner, trustMap); - } trust = readTrust(owner, fingerprint); - trustMap.put(fingerprint, trust); return trust; } @Override public void setTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint, Trust trust) throws IOException { - Map trustMap = trustCache.get(owner); - if (trustMap == null) { - trustMap = new HashMap<>(); - trustCache.put(owner, trustMap); - } - - if (trustMap.get(fingerprint) == trust) { - return; - } - - trustMap.put(fingerprint, trust); writeTrust(owner, fingerprint, trust); } }