[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,9 +2926,14 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
|
|
||||||
if (randomBoolean() && searchers.size() > 1) {
|
if (randomBoolean() && searchers.size() > 1) {
|
||||||
// Close one of the searchers at random
|
// Close one of the searchers at random
|
||||||
Engine.Searcher searcher = searchers.remove(0);
|
synchronized (searchers) {
|
||||||
logger.debug("--> {} closing searcher {}", threadName, searcher.source());
|
// re-check because it could have decremented after the check
|
||||||
IOUtils.close(searcher);
|
if (searchers.size() > 1) {
|
||||||
|
Engine.Searcher searcher = searchers.remove(0);
|
||||||
|
logger.debug("--> {} closing searcher {}", threadName, searcher.source());
|
||||||
|
IOUtils.close(searcher);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("--> got exception: ", e);
|
logger.warn("--> got exception: ", e);
|
||||||
|
|
Loading…
Reference in New Issue