lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r519006 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/Term.java src/test/org/apache/lucene/index/TestTerm.java
Date Fri, 16 Mar 2007 15:21:06 GMT
Author: otis
Date: Fri Mar 16 08:21:05 2007
New Revision: 519006

URL: http://svn.apache.org/viewvc?view=rev&rev=519006
Log:
-LUCENE-828: Term equals(Object) fix

Added:
    lucene/java/trunk/src/test/org/apache/lucene/index/TestTerm.java
Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/Term.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=519006&r1=519005&r2=519006
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Mar 16 08:21:05 2007
@@ -77,6 +77,9 @@
     
 10. LUCENE-829: close readers in contrib/benchmark. (Karl Wettin, Doron Cohen)
 
+11. LUCENE-828: Minor fix for Term's equal().
+    (Paul Cowan via Otis Gospodnetic)
+
 New features
 
  1. LUCENE-759: Added two n-gram-producing TokenFilters.

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/Term.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/Term.java?view=diff&rev=519006&r1=519005&r2=519006
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/Term.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/Term.java Fri Mar 16 08:21:05 2007
@@ -63,7 +63,11 @@
   /** Compares two terms, returning true iff they have the same
       field and text. */
   public final boolean equals(Object o) {
+    if (o == this)
+      return true;
     if (o == null)
+      return false;
+    if (!(o instanceof Term))
       return false;
     Term other = (Term)o;
     return field == other.field && text.equals(other.text);

Added: lucene/java/trunk/src/test/org/apache/lucene/index/TestTerm.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTerm.java?view=auto&rev=519006
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTerm.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTerm.java Fri Mar 16 08:21:05 2007
@@ -0,0 +1,19 @@
+package org.apache.lucene.index;
+
+import junit.framework.TestCase;
+
+public class TestTerm extends TestCase {
+
+  public void testEquals() {
+    final Term base = new Term("same", "same");
+    final Term same = new Term("same", "same");
+    final Term differentField = new Term("different", "same");
+    final Term differentText = new Term("same", "different");
+    final String differentType = "AString";
+    assertEquals(base, base);
+    assertEquals(base, same);
+    assertFalse(base.equals(differentField));
+    assertFalse(base.equals(differentText));
+    assertFalse(base.equals(differentType));
+  }
+}



Mime
View raw message