[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:
parent
53d1cde7bc
commit
7c201a64b5
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue