diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java index 899f9c3cdf9..cd134d7b276 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java +++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java @@ -512,7 +512,7 @@ public class QueryUtils { @Override public LeafReader getLastReader() { - return null; + return lastReader; } }; } @@ -522,7 +522,9 @@ public class QueryUtils { Collection collectors) { List lastReaders = new ArrayList<>(); for (SimpleCollectorWithLastReader collector : collectors) { - lastReaders.add(collector.getLastReader()); + if (collector.getLastReader() != null) { + lastReaders.add(collector.getLastReader()); + } } return lastReaders; } @@ -692,7 +694,9 @@ public class QueryUtils { public List reduce(Collection collectors) { List lastReaders = new ArrayList<>(); for (SimpleCollectorWithLastReader collector : collectors) { - lastReaders.add(collector.getLastReader()); + if (collector.getLastReader() != null) { + lastReaders.add(collector.getLastReader()); + } } return lastReaders; }