Skip to content

Commit 0b4e18c

Browse files
committed
Wait 1s for the background thread to die
1 parent a2fda5a commit 0b4e18c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,13 @@ public void testGetStepMultithreaded() throws Exception {
511511

512512
// now, in another thread, update the registry repeatedly as fast as possible.
513513
// updating the registry has the side effect of clearing the cache.
514-
new Thread(() -> {
514+
Thread t = new Thread(() -> {
515515
latch.countDown(); // signal that we're starting
516516
while (done.get() == false) {
517517
registry.update(meta);
518518
}
519-
}).start();
519+
});
520+
t.start();
520521

521522
try {
522523
latch.await(); // wait until the other thread started
@@ -530,8 +531,9 @@ public void testGetStepMultithreaded() throws Exception {
530531
assertThat(actualStep.getKey(), equalTo(step.getKey()));
531532
}
532533
} finally {
533-
// tell the other thread we're finished
534+
// tell the other thread we're finished and wait for it to die
534535
done.set(true);
536+
t.join(1000);
535537
}
536538
}
537539
}

0 commit comments

Comments
 (0)