From: David ‘Bombe’ Roden Date: Fri, 29 Oct 2010 20:12:35 +0000 (+0200) Subject: Use marker variable for whether the contexts have been loaded. X-Git-Tag: 0.2-RC1~92 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=902c5b14f671d84e90ed31cc738fd46560fe4fbd;p=Sone.git Use marker variable for whether the contexts have been loaded. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java index 2909936..090bf7f 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -45,6 +45,9 @@ public class Identity { /** The contexts of the identity. */ protected final Set contexts = Collections.synchronizedSet(new HashSet()); + /** Whether the contexts have already been loaded. */ + private volatile boolean contextsLoaded = false; + /** The properties of the identity. */ private final Map properties = Collections.synchronizedMap(new HashMap()); @@ -121,8 +124,9 @@ public class Identity { * plugin */ public Set getContexts(boolean forceReload) throws PluginException { - if (contexts.isEmpty() || forceReload) { + if (!contextsLoaded || forceReload) { Set contexts = webOfTrustConnector.loadIdentityContexts(this); + contextsLoaded = true; this.contexts.clear(); this.contexts.addAll(contexts); }