Store own identity ID instead of own identity.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 15 Sep 2011 14:35:17 +0000 (16:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 15 Sep 2011 14:35:17 +0000 (16:35 +0200)
This prevents an old identity object from being cached forever in the
resolver.

src/main/java/net/pterodactylus/wotns/main/Resolver.java
src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java

index 4dacad9..f623e3d 100644 (file)
@@ -40,14 +40,14 @@ public class Resolver {
 
        private final IdentityManager identityManager;
 
-       private OwnIdentity ownIdentity;
+       private String ownIdentityId;
 
        public Resolver(IdentityManager identityManager) {
                this.identityManager = identityManager;
        }
 
-       public void setOwnIdentity(OwnIdentity ownIdentity) {
-               this.ownIdentity = ownIdentity;
+       public void setOwnIdentityId(String ownIdentityId) {
+               this.ownIdentityId = ownIdentityId;
        }
 
        //
@@ -83,7 +83,7 @@ public class Resolver {
                }
                @SuppressWarnings("hiding")
                final OwnIdentity ownIdentity;
-               if (this.ownIdentity == null) {
+               if (this.ownIdentityId == null) {
                        Set<OwnIdentity> ownIdentities = identityManager.getAllOwnIdentities();
                        if (!ownIdentities.isEmpty()) {
                                ownIdentity = ownIdentities.iterator().next();
@@ -91,7 +91,7 @@ public class Resolver {
                                ownIdentity = null;
                        }
                } else {
-                       ownIdentity = this.ownIdentity;
+                       ownIdentity = identityManager.getOwnIdentity(ownIdentityId);
                }
                if (ownIdentity == null) {
                        return null;
index f3ec6d4..e4cad46 100644 (file)
@@ -21,7 +21,6 @@ import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.version.Version;
 import net.pterodactylus.wotns.freenet.plugin.PluginConnector;
 import net.pterodactylus.wotns.freenet.wot.IdentityManager;
-import net.pterodactylus.wotns.freenet.wot.OwnIdentity;
 import net.pterodactylus.wotns.freenet.wot.WebOfTrustConnector;
 import net.pterodactylus.wotns.ui.web.WebInterface;
 import freenet.client.HighLevelSimpleClient;
@@ -99,8 +98,7 @@ public class WoTNSPlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL1
                identityManager.start();
 
                resolver = new Resolver(identityManager);
-               OwnIdentity bombeIdentity = identityManager.getOwnIdentity("e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U");
-               resolver.setOwnIdentity(bombeIdentity);
+               resolver.setOwnIdentityId("e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U");
 
                webInterface = new WebInterface(this);