From 13ea880508643cdf0ce46e7acd5052147cebd0f5 Mon Sep 17 00:00:00 2001 From: Dmitry Cherniachenko <2sabio@gmail.com> Date: Tue, 30 Jan 2024 11:47:00 +0100 Subject: [PATCH] Align instanceof check with type cast (#13039) --- .../analysis/tokenattributes/PayloadAttributeImpl.java | 2 +- .../standard/processors/AnalyzerQueryNodeProcessor.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java index b17f0183313..4ab42576ea9 100644 --- a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java +++ b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java @@ -62,7 +62,7 @@ public class PayloadAttributeImpl extends AttributeImpl implements PayloadAttrib return true; } - if (other instanceof PayloadAttribute) { + if (other instanceof PayloadAttributeImpl) { PayloadAttributeImpl o = (PayloadAttributeImpl) other; if (o.payload == null || payload == null) { return o.payload == null && payload == null; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java index 282a0a2d08a..26746a6b0ed 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java @@ -38,13 +38,11 @@ import org.apache.lucene.queryparser.flexible.core.nodes.NoTokenFoundQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.RangeQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.TextableQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.TokenizedPhraseQueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys; import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.Operator; import org.apache.lucene.queryparser.flexible.standard.nodes.MultiPhraseQueryNode; -import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.SynonymQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; @@ -107,10 +105,9 @@ public class AnalyzerQueryNodeProcessor extends QueryNodeProcessorImpl { @Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - if (node instanceof TextableQueryNode + if (node instanceof FieldQueryNode && !(node instanceof WildcardQueryNode) && !(node instanceof FuzzyQueryNode) - && !(node instanceof RegexpQueryNode) && !(node.getParent() instanceof RangeQueryNode)) { FieldQueryNode fieldNode = ((FieldQueryNode) node);