From 2185a5cfb74ea5666971e1133f001a9f89c6e7cf Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 5 Jun 2006 20:48:48 +0000 Subject: [PATCH] prevention of possible ConcurrentModificationException This happend at my peer and created a deadlock. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2179 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/index/indexTreeMapContainer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/de/anomic/index/indexTreeMapContainer.java b/source/de/anomic/index/indexTreeMapContainer.java index 4857be021..390278670 100644 --- a/source/de/anomic/index/indexTreeMapContainer.java +++ b/source/de/anomic/index/indexTreeMapContainer.java @@ -108,12 +108,14 @@ public final class indexTreeMapContainer extends indexAbstractContainer implemen // returns the number of new elements long startTime = System.currentTimeMillis(); if (c == null) return 0; - Iterator i = c.entries(); int x = 0; - while ((i.hasNext()) && ((maxTime < 0) || ((startTime + maxTime) > System.currentTimeMillis()))) { - try { - if (addi((indexURLEntry) i.next())) x++; - } catch (ConcurrentModificationException e) {} + synchronized (c) { + Iterator i = c.entries(); + while ((i.hasNext()) && ((maxTime < 0) || ((startTime + maxTime) > System.currentTimeMillis()))) { + try { + if (addi((indexURLEntry) i.next())) x++; + } catch (ConcurrentModificationException e) {} + } } this.updateTime = java.lang.Math.max(this.updateTime, c.updated()); return x;