X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FDefaultIdentity.java;h=6fe4101b6588dd585dc1ea1667e466aed9d062ca;hp=3f4e66ad788d1c5d718d636594fdf8482e6bf42e;hb=480691a26222e035e53bda56029524e160fdf898;hpb=d53a79eeb9531a08173431ce2ba19156eeca4a0c diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java index 3f4e66a..6fe4101 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultIdentity.java - Copyright © 2010 David Roden + * Sone - DefaultIdentity.java - Copyright © 2010–2012 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,6 +64,7 @@ public class DefaultIdentity implements Identity { private final Map properties = Collections.synchronizedMap(new HashMap()); /** Cached trust. */ + /* synchronize on itself. */ private final WritableCache trustCache = new MemoryCache(new ValueRetriever() { @Override @@ -76,7 +77,7 @@ public class DefaultIdentity implements Identity { } } - }, new TimedMap>(60000)); + }, new TimedMap>(60 * 60 * 1000)); /** * Creates a new identity. @@ -249,9 +250,11 @@ public class DefaultIdentity implements Identity { @Override public Trust getTrust(OwnIdentity ownIdentity) { try { - return trustCache.get(ownIdentity); + synchronized (trustCache) { + return trustCache.get(ownIdentity); + } } catch (CacheException ce1) { - logger.log(Level.WARNING, "Could not get trust for OwnIdentity: " + ownIdentity, ce1); + logger.log(Level.WARNING, String.format("Could not get trust for OwnIdentity: %s", ownIdentity), ce1); return null; } } @@ -265,7 +268,9 @@ public class DefaultIdentity implements Identity { * The trust received for this identity */ void setTrustPrivate(OwnIdentity ownIdentity, Trust trust) { - trustCache.put(ownIdentity, trust); + synchronized (trustCache) { + trustCache.put(ownIdentity, trust); + } } //