Index: src/java/org/apache/lucene/index/Term.java =================================================================== --- src/java/org/apache/lucene/index/Term.java (revision 512303) +++ src/java/org/apache/lucene/index/Term.java (working copy) @@ -76,16 +76,26 @@ return compareTo((Term)other); } - /** Compares two terms, returning a negative integer if this - term belongs before the argument, zero if this term is equal to the - argument, and a positive integer if this term belongs after the argument. - - The ordering of terms is first by field, then by text.*/ - public final int compareTo(Term other) { - if (field == other.field) // fields are interned - return text.compareTo(other.text); - else - return field.compareTo(other.field); + /** + * Compares two terms, returning a negative integer if this term + * belongs before the argument, 0 (zero) if this term is equal to the + * argument, and a positive integer if this term belongs after the + * argument. The ordering of terms is first by field, then by text. + */ + public final int compareTo( final Term other ) { + if ( field == other.field ) { // fields are interned + if ( text == null && other.text == null ) { + return 0; + } else if ( text == null ) { + return -1; + } else if ( other.text == null ) { + return 1; + } else { + return text.compareTo( other.text ); + } + } else { + return field.compareTo( other.field ); + } } /** Resets the field and text of a Term. */