diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java index cb59cc0e04c..aff689306fc 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -957,12 +958,18 @@ public class TestLRUQueryCache extends LuceneTestCase { BadQuery query = new BadQuery(); searcher.count(query); query.i[0] += 1; // change the hashCode! + try { // trigger an eviction searcher.count(new MatchAllDocsQuery()); fail(); } catch (ConcurrentModificationException e) { // expected + } catch (RuntimeException e) { + // expected: wrapped when executor is in use + Throwable cause = e.getCause(); + assertTrue(cause instanceof ExecutionException); + assertTrue(cause.getCause() instanceof ConcurrentModificationException); } IOUtils.close(w, reader, dir);