diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 014b2d23aec..4cc338c789f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -194,13 +194,16 @@ public class RoutingNodes implements Iterable { public List shardsRoutingFor(String index, int shardId) { List shards = newArrayList(); for (RoutingNode routingNode : this) { - for (MutableShardRouting shardRouting : routingNode) { + List nShards = routingNode.shards(); + for (int i = 0; i < nShards.size(); i++) { + MutableShardRouting shardRouting = nShards.get(i); if (shardRouting.index().equals(index) && shardRouting.id() == shardId) { shards.add(shardRouting); } } } - for (MutableShardRouting shardRouting : unassigned) { + for (int i = 0; i < unassigned.size(); i++) { + MutableShardRouting shardRouting = unassigned.get(i); if (shardRouting.index().equals(index) && shardRouting.id() == shardId) { shards.add(shardRouting); }