[TEST] Synchronize searcher list in IndexShardTests

It's possible to check the list size, then attempt to remove a searcher and
throw an IndexOutOfBoundsException due to multiple threads.

Resolves #27651
This commit is contained in:
Lee Hinman 2018-02-13 12:11:15 -07:00
parent 53d1cde7bc
commit 7c201a64b5
1 changed files with 8 additions and 3 deletions

View File

@ -2926,10 +2926,15 @@ public class IndexShardTests extends IndexShardTestCase {
if (randomBoolean() && searchers.size() > 1) {
// Close one of the searchers at random
synchronized (searchers) {
// re-check because it could have decremented after the check
if (searchers.size() > 1) {
Engine.Searcher searcher = searchers.remove(0);
logger.debug("--> {} closing searcher {}", threadName, searcher.source());
IOUtils.close(searcher);
}
}
}
} catch (Exception e) {
logger.warn("--> got exception: ", e);
fail("got an exception we didn't expect");