From d3c923e6b92343f78ebb1a3f7c7b4e14dbec6746 Mon Sep 17 00:00:00 2001 From: theli Date: Sat, 10 Sep 2005 05:42:30 +0000 Subject: [PATCH] *) Bugfix for "ConcurrentModificationException in hello.class" See: http://www.yacy-forum.de/viewtopic.php?t=723 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@694 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/yacy/yacySeed.java | 41 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index a640b9d47..ae0279908 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -65,10 +65,9 @@ import java.io.FileWriter; import java.io.IOException; import java.util.Date; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; import java.util.Properties; -import java.util.StringTokenizer; - import de.anomic.net.natLib; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverCodings; @@ -87,20 +86,25 @@ public class yacySeed { // class variables public String hash; - private Map dna; + private final Hashtable dna = new Hashtable(25); public int available; public int selectscore = -1; // only for debugging public yacySeed(String hash, Map dna) { - // create a seed with a pre-defined hash map - this.hash = hash; - this.dna = dna; + // create a seed with a pre-defined hash map + this.hash = hash; + this.dna.putAll(dna); this.available = 0; } + + public yacySeed(String hash, Hashtable dna) { + // create a seed with a pre-defined hash table + this.hash = hash; + this.dna.putAll(dna); + this.available = 0; + } public yacySeed(String hash) { - dna = new HashMap(); - // settings that can only be computed by originating peer: // at first startup - this.hash = hash; // the hash key of the peer - very important. should be static somehow, even after restart @@ -364,15 +368,16 @@ public class yacySeed { public String toString() { String s = null; - synchronized (dna) { - // set hash into seed code structure - dna.put("Hash", this.hash); - // generate string representation - s = dna.toString(); - // reconstruct original: hash is stored external - dna.remove("Hash"); - // return string - } + + Hashtable dnaClone = (Hashtable) dna.clone(); + + // set hash into seed code structure + dnaClone.put("Hash", this.hash); + + // generate string representation + s = dnaClone.toString(); + + // return string return s; } @@ -413,7 +418,7 @@ public class yacySeed { } public Object clone() { - return new yacySeed(this.hash, (HashMap) (new HashMap(dna)).clone()); + return new yacySeed(this.hash, (Hashtable)dna.clone()); } /*