From bb43636190086dc8ff627ac0047344971b6def14 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 25 Jul 2013 18:18:41 +0200 Subject: [PATCH] break out if there no more liveIds. This can happen if another thread emptied the liveIds. --- .../integration/percolator/ConcurrentPercolatorTests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/integration/percolator/ConcurrentPercolatorTests.java b/src/test/java/org/elasticsearch/test/integration/percolator/ConcurrentPercolatorTests.java index 8874ccec602..ef006f0d64e 100644 --- a/src/test/java/org/elasticsearch/test/integration/percolator/ConcurrentPercolatorTests.java +++ b/src/test/java/org/elasticsearch/test/integration/percolator/ConcurrentPercolatorTests.java @@ -78,7 +78,7 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests { } @Test - public void testSimpleConcurrentPerculator() throws Exception { + public void testSimpleConcurrentPercolator() throws Exception { client().admin().indices().prepareCreate("index").setSettings( ImmutableSettings.settingsBuilder() .put("index.number_of_shards", 1) @@ -344,12 +344,15 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests { try { XContentBuilder doc = XContentFactory.jsonBuilder().startObject() .field("query", termQuery("field1", "value")).endObject(); - while (run.get()) { + outer: while (run.get()) { semaphore.acquire(); try { if (!liveIds.isEmpty() && getRandom().nextInt(100) < 19) { String id; do { + if (liveIds.isEmpty()) { + continue outer; + } id = Integer.toString(randomInt(idGen.get())); } while (!liveIds.remove(id));