[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
@@ -2781,10 +2781,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");
