From 902c5b14f671d84e90ed31cc738fd46560fe4fbd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 29 Oct 2010 22:12:35 +0200 Subject: [PATCH] Use marker variable for whether the contexts have been loaded. --- src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } -- 2.7.4