zhaih commented on code in PR #11840: URL: https://github.com/apache/lucene/pull/11840#discussion_r998828034
########## lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/TestFieldQuery.java: ########## @@ -40,12 +41,23 @@ public class TestFieldQuery extends AbstractTestCase { private float boost; + private IndexSearcher searcher; /** Set boost to a random value each time it is called. */ private void initBoost() { boost = usually() ? 1F : random().nextFloat() * 10000; } + @Override + public void setUp() throws Exception { + super.setUp(); + if (reader == null) { + searcher = null; + } else { + searcher = newSearcher(reader); + } + } Review Comment: It works.. with flaws, since if one of the unit test alters the reader and the reader become non-null in this way searcher stays null. (Altho I personally don't like the pattern where a shared member will be altered within test) > Should we instead modify the parent class to always instantiate an IndexSearcher when instantiating a reader? Yeah that's better, I changed accordingly, thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org