summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/java/org/elasticsearch/index/IndexServiceTests.java')
-rw-r--r--core/src/test/java/org/elasticsearch/index/IndexServiceTests.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
index 3a4020e410..97258b12a3 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
@@ -187,12 +187,13 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
return ThreadPool.Names.GENERIC;
}
};
+
latch.get().await();
latch.set(new CountDownLatch(1));
assertEquals(1, count.get());
- latch2.get().countDown();
- latch2.set(new CountDownLatch(1));
-
+ // here we need to swap first before we let it go otherwise threads might be very fast and run that task twice due to
+ // random exception and the schedule interval is 1ms
+ latch2.getAndSet(new CountDownLatch(1)).countDown();
latch.get().await();
assertEquals(2, count.get());
task.close();