From feb824e20978e70ab099012a2a46cdcfc73c6dfc Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Tue, 10 Sep 2024 10:05:44 -0700 Subject: [PATCH] Fix null checks Signed-off-by: Harsha Vamsi Kalluri --- .../org/apache/lucene/tests/search/QueryUtils.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; }