From 78fc7fed7c6c98052bf4299ca91c55f44be71947 Mon Sep 17 00:00:00 2001 From: skyguard1 Date: Thu, 16 Sep 2021 21:05:05 +0800 Subject: [PATCH] Use Objects.equals() instead of == to compare strings (#77840) --- .../common/lucene/search/MultiPhrasePrefixQuery.java | 2 +- .../java/org/elasticsearch/xpack/ql/index/IndexResolver.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java b/server/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java index 87895bc91129c..99d705eece950 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java @@ -97,7 +97,7 @@ public void add(Term[] terms) { */ public void add(Term[] terms, int position) { for (int i = 0; i < terms.length; i++) { - if (terms[i].field() != field) { + if (Objects.equals(terms[i].field(), field) == false) { throw new IllegalArgumentException( "All phrase terms must be in the same field (" + field + "): " + terms[i]); diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java index 50f3e9092bc7f..46c59ef1037ff 100644 --- a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java @@ -710,7 +710,7 @@ private static Map getInvalidFieldsForAliases(String // iterate over each type for (Entry type : types.entrySet()) { String esFieldType = type.getKey(); - if (esFieldType == UNMAPPED) { + if (Objects.equals(esFieldType, UNMAPPED)) { continue; } String[] indices = type.getValue().indices(); @@ -749,7 +749,7 @@ private static Map getInvalidFieldsForAliases(String } else { // if the field type is the same across all this alias' indices, check the field's capabilities (searchable/aggregatable) for (Entry type : types.entrySet()) { - if (type.getKey() == UNMAPPED) { + if (Objects.equals(type.getKey(), UNMAPPED)) { continue; } FieldCapabilities f = type.getValue();