diff --git a/server/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java b/server/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java index 0303c5cd7157a..3cb62e8428559 100644 --- a/server/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java +++ b/server/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java @@ -116,7 +116,7 @@ public String toString(String field) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (sameClassAs(o) == false) return false; BinaryDocValuesRangeQuery that = (BinaryDocValuesRangeQuery) o; return Objects.equals(fieldName, that.fieldName) && queryType == that.queryType && @@ -127,7 +127,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(getClass(), fieldName, queryType, lengthType, from, to); + return Objects.hash(classHash(), fieldName, queryType, lengthType, from, to); } public enum QueryType { diff --git a/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreQuery.java b/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreQuery.java index cfbe9440998e3..1fa84837452eb 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreQuery.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreQuery.java @@ -174,7 +174,7 @@ public String toString(String field) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (sameClassAs(o) == false) return false; ScriptScoreQuery that = (ScriptScoreQuery) o; return shardId == that.shardId && subQuery.equals(that.subQuery) && @@ -186,7 +186,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(subQuery, script, minScore, indexName, shardId, indexVersion); + return Objects.hash(classHash(), subQuery, script, minScore, indexName, shardId, indexVersion); } diff --git a/server/src/main/java/org/elasticsearch/index/query/DateRangeIncludingNowQuery.java b/server/src/main/java/org/elasticsearch/index/query/DateRangeIncludingNowQuery.java index e3012f10947a8..3c1bbefcacca7 100644 --- a/server/src/main/java/org/elasticsearch/index/query/DateRangeIncludingNowQuery.java +++ b/server/src/main/java/org/elasticsearch/index/query/DateRangeIncludingNowQuery.java @@ -51,13 +51,13 @@ public void visit(QueryVisitor visitor) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (sameClassAs(o) == false) return false; DateRangeIncludingNowQuery that = (DateRangeIncludingNowQuery) o; return Objects.equals(in, that.in); } @Override public int hashCode() { - return Objects.hash(in); + return Objects.hash(classHash(), in); } } diff --git a/server/src/main/java/org/elasticsearch/index/search/ESToParentBlockJoinQuery.java b/server/src/main/java/org/elasticsearch/index/search/ESToParentBlockJoinQuery.java index fac0f0f7ae9a3..67ec03b291548 100644 --- a/server/src/main/java/org/elasticsearch/index/search/ESToParentBlockJoinQuery.java +++ b/server/src/main/java/org/elasticsearch/index/search/ESToParentBlockJoinQuery.java @@ -94,7 +94,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { - return Objects.hash(getClass(), query, path); + return Objects.hash(classHash(), query, path); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/shard/ShardSplittingQuery.java b/server/src/main/java/org/elasticsearch/index/shard/ShardSplittingQuery.java index c21eb9274c418..2afc267bff7a3 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/ShardSplittingQuery.java +++ b/server/src/main/java/org/elasticsearch/index/shard/ShardSplittingQuery.java @@ -170,7 +170,7 @@ public String toString(String field) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (sameClassAs(o) == false) return false; ShardSplittingQuery that = (ShardSplittingQuery) o; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/MergedPointRangeQuery.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/MergedPointRangeQuery.java index 5d965a3e6348d..226ea637457b1 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/MergedPointRangeQuery.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/MergedPointRangeQuery.java @@ -172,7 +172,7 @@ public String toString(String field) { @Override public boolean equals(Object obj) { - if (obj == null || obj.getClass() != getClass()) { + if (sameClassAs(obj) == false) { return false; } MergedPointRangeQuery other = (MergedPointRangeQuery) obj; diff --git a/server/src/main/java/org/elasticsearch/search/runtime/AbstractScriptFieldQuery.java b/server/src/main/java/org/elasticsearch/search/runtime/AbstractScriptFieldQuery.java index bcfece28b063c..c73891b799958 100644 --- a/server/src/main/java/org/elasticsearch/search/runtime/AbstractScriptFieldQuery.java +++ b/server/src/main/java/org/elasticsearch/search/runtime/AbstractScriptFieldQuery.java @@ -99,12 +99,12 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio @Override public int hashCode() { - return Objects.hash(getClass(), script, fieldName); + return Objects.hash(classHash(), script, fieldName); } @Override public boolean equals(Object obj) { - if (obj == null || getClass() != obj.getClass()) { + if (sameClassAs(obj) == false) { return false; } AbstractScriptFieldQuery other = (AbstractScriptFieldQuery) obj; diff --git a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/AutomatonQueryOnBinaryDv.java b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/AutomatonQueryOnBinaryDv.java index 591ebd98d2ce7..6dbc342372905 100644 --- a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/AutomatonQueryOnBinaryDv.java +++ b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/AutomatonQueryOnBinaryDv.java @@ -90,9 +90,9 @@ public String toString(String field) { @Override public boolean equals(Object obj) { - if (obj == null || obj.getClass() != getClass()) { + if (sameClassAs(obj) == false) { return false; - } + } AutomatonQueryOnBinaryDv other = (AutomatonQueryOnBinaryDv) obj; return Objects.equals(field, other.field) && Objects.equals(matchPattern, other.matchPattern) && Objects.equals(bytesMatcher, other.bytesMatcher); @@ -100,7 +100,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { - return Objects.hash(field, matchPattern, bytesMatcher); + return Objects.hash(classHash(), field, matchPattern, bytesMatcher); } }