diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardOperationsLockTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardOperationsLockTests.java index 9ac9e86fec8..c9bb9e19866 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardOperationsLockTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardOperationsLockTests.java @@ -92,10 +92,12 @@ public class IndexShardOperationsLockTests extends ESTestCase { operationThreads.add(thread); } + CountDownLatch blockFinished = new CountDownLatch(1); threadPool.generic().execute(() -> { try { latch.await(); blockAndWait().close(); + blockFinished.countDown(); } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -112,6 +114,8 @@ public class IndexShardOperationsLockTests extends ESTestCase { for (Thread thread : operationThreads) { thread.join(); } + + blockFinished.await(); }