From 176f359e8b59dfb72a2789347f026cdda143ee9f Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 11 May 2011 01:59:14 +0300 Subject: [PATCH] Possible failure when using TransportClient (with sniffing), closes #923. --- .../client/transport/TransportClientNodesService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index ae927d3ec82..4dc6cad1868 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -36,6 +36,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.*; import java.util.HashSet; +import java.util.Iterator; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledFuture; @@ -255,11 +256,12 @@ public class TransportClientNodesService extends AbstractComponent { } } // now, make sure we are connected to all the updated nodes - for (DiscoveryNode node : newNodes) { + for (Iterator it = newNodes.iterator(); it.hasNext();) { + DiscoveryNode node = it.next(); try { transportService.connectToNode(node); } catch (Exception e) { - newNodes.remove(node); + it.remove(); logger.debug("Failed to connect to discovered node [" + node + "]", e); } }