Skip to content

Commit 9984c48

Browse files
authored
Use Objects.equals() instead of == to compare strings (#77840)
1 parent fec5e8a commit 9984c48

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

server/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void add(Term[] terms) {
9797
*/
9898
public void add(Term[] terms, int position) {
9999
for (int i = 0; i < terms.length; i++) {
100-
if (terms[i].field() != field) {
100+
if (Objects.equals(terms[i].field(), field) == false) {
101101
throw new IllegalArgumentException(
102102
"All phrase terms must be in the same field (" + field + "): "
103103
+ terms[i]);

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ private static Map<String, InvalidMappedField> getInvalidFieldsForAliases(String
710710
// iterate over each type
711711
for (Entry<String, FieldCapabilities> type : types.entrySet()) {
712712
String esFieldType = type.getKey();
713-
if (esFieldType == UNMAPPED) {
713+
if (Objects.equals(esFieldType, UNMAPPED)) {
714714
continue;
715715
}
716716
String[] indices = type.getValue().indices();
@@ -749,7 +749,7 @@ private static Map<String, InvalidMappedField> getInvalidFieldsForAliases(String
749749
} else {
750750
// if the field type is the same across all this alias' indices, check the field's capabilities (searchable/aggregatable)
751751
for (Entry<String, FieldCapabilities> type : types.entrySet()) {
752-
if (type.getKey() == UNMAPPED) {
752+
if (Objects.equals(type.getKey(), UNMAPPED)) {
753753
continue;
754754
}
755755
FieldCapabilities f = type.getValue();

0 commit comments

Comments
 (0)