diff --git a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java index cd44ab5e1b2..144070e1d9b 100644 --- a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java @@ -386,12 +386,10 @@ public class TermInSetQuery extends Query implements Accountable { @Override public Scorer get(long leadCost) throws IOException { WeightOrDocIdSet weightOrDocIdSet = rewrite(context); - if (weightOrDocIdSet == null) { - return null; - } - final Scorer scorer; - if (weightOrDocIdSet.weight != null) { + if (weightOrDocIdSet == null) { + scorer = null; + } else if (weightOrDocIdSet.weight != null) { scorer = weightOrDocIdSet.weight.scorer(context); } else { scorer = scorer(weightOrDocIdSet.set);