break out if there no more liveIds. This can happen if another thread emptied the liveIds.

This commit is contained in:
Martijn van Groningen 2013-07-25 18:18:41 +02:00
parent 60f095bb72
commit bb43636190
1 changed files with 5 additions and 2 deletions

View File

@ -78,7 +78,7 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests {
} }
@Test @Test
public void testSimpleConcurrentPerculator() throws Exception { public void testSimpleConcurrentPercolator() throws Exception {
client().admin().indices().prepareCreate("index").setSettings( client().admin().indices().prepareCreate("index").setSettings(
ImmutableSettings.settingsBuilder() ImmutableSettings.settingsBuilder()
.put("index.number_of_shards", 1) .put("index.number_of_shards", 1)
@ -344,12 +344,15 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests {
try { try {
XContentBuilder doc = XContentFactory.jsonBuilder().startObject() XContentBuilder doc = XContentFactory.jsonBuilder().startObject()
.field("query", termQuery("field1", "value")).endObject(); .field("query", termQuery("field1", "value")).endObject();
while (run.get()) { outer: while (run.get()) {
semaphore.acquire(); semaphore.acquire();
try { try {
if (!liveIds.isEmpty() && getRandom().nextInt(100) < 19) { if (!liveIds.isEmpty() && getRandom().nextInt(100) < 19) {
String id; String id;
do { do {
if (liveIds.isEmpty()) {
continue outer;
}
id = Integer.toString(randomInt(idGen.get())); id = Integer.toString(randomInt(idGen.get()));
} while (!liveIds.remove(id)); } while (!liveIds.remove(id));