Apache Lucene open-source search software
LUCENE-1840: QueryUtils should check that equals() properly handles null
Robert Muirf8c0293d854d
diff --git a/lucene/src/java/org/apache/lucene/search/function/CustomScoreQuery.java b/lucene/src/java/org/apache/lucene/search/function/CustomScoreQuery.javaindex 683334ce98f..4be1ae334bb 100755--- a/lucene/src/java/org/apache/lucene/search/function/CustomScoreQuery.java+++ b/lucene/src/java/org/apache/lucene/search/function/CustomScoreQuery.java@@ -145,6 +145,10 @@ public class CustomScoreQuery extends Query {/** Returns true if <code>o</code> is equal to this. */@Overridepublic boolean equals(Object o) {+ if (this == o)+ return true;+ if (!super.equals(o))+ return false;if (getClass() != o.getClass()) {return false;}diff --git a/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java b/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.javaindex b76ecf49cc9..a0387fc1f9a 100644--- a/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java+++ b/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java@@ -185,6 +185,10 @@ public class ValueSourceQuery extends Query {/** Returns true if <code>o</code> is equal to this. */@Overridepublic boolean equals(Object o) {+ if (this == o)+ return true;+ if (!super.equals(o))+ return false;if (getClass() != o.getClass()) {return false;}diff --git a/lucene/src/test/org/apache/lucene/search/QueryUtils.java b/lucene/src/test/org/apache/lucene/search/QueryUtils.javaindex e41cb989340..8a4266b8525 100644--- a/lucene/src/test/org/apache/lucene/search/QueryUtils.java+++ b/lucene/src/test/org/apache/lucene/search/QueryUtils.java@@ -64,6 +64,9 @@ public class QueryUtils {};whacky.setBoost(q.getBoost());checkUnequal(q, whacky);++ // null test+ Assert.assertFalse(q.equals(null));}public static void checkEqual(Query q1, Query q2) {