fixed concurrentModificationException during hello-process

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4693 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 64c33e717f
commit 9a32a4c328

@ -47,6 +47,7 @@
// if the shell's current path is HTROOT
import java.net.InetAddress;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
@ -210,10 +211,12 @@ public final class hello {
Iterator<yacySeed> si = ySeeds.values().iterator();
yacySeed s;
while (si.hasNext()) {
s = (yacySeed) si.next();
if ((s != null) && (s.isProper() == null)) {
s = si.next();
if ((s != null) && (s.isProper() == null)) try {
seeds.append("seed").append(count).append('=').append(s.genSeedStr(key)).append(serverCore.CRLF_STRING);
count++;
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
}

@ -195,18 +195,19 @@ public final class serverCodings {
}
public static String map2string(Map<String, String> m, String separator, boolean braces) {
final StringBuffer buf = new StringBuffer(20 * m.size());
if (braces) { buf.append("{"); }
final Iterator<Map.Entry<String, String>> i = m.entrySet().iterator();
while (i.hasNext()) {
final Entry<String, String> e = i.next();
buf.append(e.getKey()).append('=');
if (e.getValue() != null) { buf.append(e.getValue()); }
buf.append(separator);
// m must be synchronized to prevent that a ConcurrentModificationException occurs
synchronized (m) {
final StringBuffer buf = new StringBuffer(20 * m.size());
if (braces) { buf.append("{"); }
for (Entry<String, String> e: m.entrySet()) {
buf.append(e.getKey()).append('=');
if (e.getValue() != null) { buf.append(e.getValue()); }
buf.append(separator);
}
if (buf.length() > 1) { buf.setLength(buf.length() - 1); } // remove last separator
if (braces) { buf.append("}"); }
return new String(buf);
}
if (buf.length() > 1) { buf.setLength(buf.length() - 1); } // remove last separator
if (braces) { buf.append("}"); }
return new String(buf);
}
public static Set<String> string2set(String string, String separator) {

Loading…
Cancel
Save