SOLR-12155: making TestUnInvertedFieldException more thread-safe

This commit is contained in:
Mikhail Khludnev 2018-04-18 14:57:49 +03:00
parent 507c439558
commit dbdedf3e3f
2 changed files with 7 additions and 4 deletions

View File

@ -144,7 +144,8 @@ Bug Fixes
* SOLR-12207: Just rethrowing AssertionError caused by jdk bug in reflection with invocation details.
(ab, Dawid Weiss, Mikhail Khludnev)
* SOLR-12155: Exception from UnInvertedField constructor puts threads to infinite wait. (Mikhail Khludnev)
* SOLR-12155: Exception from UnInvertedField constructor puts threads to infinite wait.
(Andrey Kudryavtsev, Mikhail Khludnev)
* SOLR-12201: TestReplicationHandler.doTestIndexFetchOnMasterRestart(): handle unexpected replication failures
(Steve Rowe)

View File

@ -34,6 +34,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.util.ExecutorUtil.MDCAwareThreadPoolExecutor;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.facet.UnInvertedField;
import org.apache.solr.util.TestInjection;
import org.junit.After;
@ -78,10 +79,11 @@ public class TestUnInvertedFieldException extends SolrTestCaseJ4 {
@Test
public void testConcurrentInit() throws Exception {
final SolrQueryRequest req = req("*:*");
final SolrIndexSearcher searcher = req.getSearcher();
List<Callable<UnInvertedField>> initCallables = new ArrayList<>();
for (int i=0;i< TestUtil.nextInt(random(), 10, 30);i++) {
initCallables.add(()-> UnInvertedField.getUnInvertedField(proto.field(), req.getSearcher()));
initCallables.add(()-> UnInvertedField.getUnInvertedField(proto.field(), searcher));
}
final ThreadPoolExecutor pool = new MDCAwareThreadPoolExecutor(3,
@ -101,7 +103,7 @@ public class TestUnInvertedFieldException extends SolrTestCaseJ4 {
assertEquals(ErrorCode.SERVER_ERROR.code, solrException.code());
assertSame(solrException.getCause().getClass(), OutOfMemoryError.class);
}
assertNull(UnInvertedField.checkUnInvertedField(proto.field(), req.getSearcher()));
assertNull(UnInvertedField.checkUnInvertedField(proto.field(), searcher));
}
TestInjection.uifOutOfMemoryError = false;
}
@ -111,7 +113,7 @@ public class TestUnInvertedFieldException extends SolrTestCaseJ4 {
for (Future<UnInvertedField> uifuture : futures) {
final UnInvertedField uif = uifuture.get();
assertNotNull(uif);
assertSame(uif, UnInvertedField.checkUnInvertedField(proto.field(), req.getSearcher()));
assertSame(uif, UnInvertedField.checkUnInvertedField(proto.field(), searcher));
if (prev != null) {
assertSame(prev, uif);
}