[freenet-dev] [freenet-cvs] r19279 - trunk/freenet/src/freenet/node
Matthew Toseland
toad at amphibian.dyndns.org
Mon Apr 14 21:18:54 UTC 2008
Umm, what do you think the synchronized() is for? Why lock an object, then
clone it, then do something with the clone, and finally unlock?
On Monday 14 April 2008 00:56, j16sdiz at freenetproject.org wrote:
> Author: j16sdiz
> Date: 2008-04-13 23:56:23 +0000 (Sun, 13 Apr 2008)
> New Revision: 19279
>
> Modified:
> trunk/freenet/src/freenet/node/LocationManager.java
> Log:
> fix concurrent modification (give NPE in gcj)
>
>
> Modified: trunk/freenet/src/freenet/node/LocationManager.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/LocationManager.java 2008-04-13 23:45:47
UTC (rev 19278)
> +++ trunk/freenet/src/freenet/node/LocationManager.java 2008-04-13 23:56:23
UTC (rev 19279)
> @@ -10,8 +10,12 @@
> import java.text.DateFormat;
> import java.util.Date;
> import java.util.Enumeration;
> +import java.util.HashSet;
> import java.util.Hashtable;
> +import java.util.Iterator;
> import java.util.LinkedList;
> +import java.util.Map;
> +import java.util.Set;
> import java.util.Vector;
>
> import freenet.crypt.RandomSource;
> @@ -1217,10 +1221,14 @@
> public void lostOrRestartedNode(PeerNode pn) {
> Vector v = new Vector();
> synchronized(recentlyForwardedIDs) {
> - Enumeration e = recentlyForwardedIDs.keys();
> - while(e.hasMoreElements()) {
> - Long l = (Long)e.nextElement();
> - RecentlyForwardedItem item =
(RecentlyForwardedItem)recentlyForwardedIDs.get(l);
> + Set entrySet = new HashSet(recentlyForwardedIDs.entrySet()); //
clone
> +
> + Iterator it = entrySet.iterator();
> + while (it.hasNext()) {
> + Map.Entry e = (Map.Entry) it.next();
> + Long l = (Long) e.getKey();
> +
> + RecentlyForwardedItem item = (RecentlyForwardedItem) e.getValue();
> if(item == null) {
> Logger.error(this, "Key is "+l+" but no value on
recentlyForwardedIDs - shouldn't be possible");
> continue;
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://emu.freenetproject.org/pipermail/devl/attachments/20080414/7c42bcdb/attachment.pgp
More information about the Devl
mailing list