Synchronize all access on the current own identities.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / IdentityManager.java
index 77e0480..6f33a4a 100644 (file)
@@ -150,7 +150,9 @@ public class IdentityManager extends AbstractService {
         * @return All own identities
         */
        public Set<OwnIdentity> getAllOwnIdentities() {
-               return new HashSet<OwnIdentity>(currentOwnIdentities.values());
+               synchronized (syncObject) {
+                       return new HashSet<OwnIdentity>(currentOwnIdentities.values());
+               }
        }
 
        //
@@ -167,12 +169,11 @@ public class IdentityManager extends AbstractService {
                        Map<OwnIdentity, Map<String, Identity>> currentIdentities = new HashMap<OwnIdentity, Map<String, Identity>>();
                        Map<String, OwnIdentity> currentOwnIdentities = new HashMap<String, OwnIdentity>();
 
-                       Set<OwnIdentity> ownIdentities = null;
                        boolean identitiesLoaded = false;
                        try {
                                /* get all identities with the wanted context from WoT. */
                                logger.finer("Getting all Own Identities from WoT...");
-                               ownIdentities = webOfTrustConnector.loadAllOwnIdentities();
+                               Set<OwnIdentity> ownIdentities = webOfTrustConnector.loadAllOwnIdentities();
                                logger.finest(String.format("Loaded %d Own Identities.", ownIdentities.size()));
 
                                /* load trusted identities. */