mirror of https://github.com/apache/lucene.git
LUCENE-1250: fix equals() to check for null and not fail on NPE (trunk)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1063272 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a20e2cd89a
commit
913a9e4491
|
@ -99,7 +99,9 @@ public class OrdFieldSource extends ValueSource {
|
|||
/*(non-Javadoc) @see java.lang.Object#equals(java.lang.Object) */
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o.getClass() != OrdFieldSource.class) return false;
|
||||
if (o == this) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != OrdFieldSource.class) return false;
|
||||
OrdFieldSource other = (OrdFieldSource)o;
|
||||
return this.field.equals(other.field);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,9 @@ public class ReverseOrdFieldSource extends ValueSource {
|
|||
/*(non-Javadoc) @see java.lang.Object#equals(java.lang.Object) */
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o.getClass() != ReverseOrdFieldSource.class) return false;
|
||||
if (o == this) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != ReverseOrdFieldSource.class) return false;
|
||||
ReverseOrdFieldSource other = (ReverseOrdFieldSource)o;
|
||||
return this.field.equals(other.field);
|
||||
}
|
||||
|
|
|
@ -254,4 +254,13 @@ public class TestOrdValues extends FunctionTestSetup {
|
|||
return getClass().getName() + "." + getName();
|
||||
}
|
||||
|
||||
// LUCENE-1250
|
||||
public void testEqualsNull() throws Exception {
|
||||
OrdFieldSource ofs = new OrdFieldSource("f");
|
||||
assertFalse(ofs.equals(null));
|
||||
|
||||
ReverseOrdFieldSource rofs = new ReverseOrdFieldSource("f");
|
||||
assertFalse(rofs.equals(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue