lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r650992 - /lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java
Date Wed, 23 Apr 2008 18:32:44 GMT
Author: mikemccand
Date: Wed Apr 23 11:32:40 2008
New Revision: 650992

URL: http://svn.apache.org/viewvc?rev=650992&view=rev
Log:
LUCENE-1255: in CheckIndex, accept pos=-1 if index is < 2.4; added NOTE to remind user
to turn on assertions for more thorough checking

Modified:
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java?rev=650992&r1=650991&r2=650992&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java Wed Apr
23 11:32:40 2008
@@ -201,7 +201,7 @@
             totPos += freq;
             for(int j=0;j<freq;j++) {
               final int pos = termPositions.nextPosition();
-              if (pos < 0)
+              if (pos < -1)
                 throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos
+ " is out of bounds");
               if (pos < lastPos)
                 throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos
+ " < lastPos " + lastPos);
@@ -318,6 +318,13 @@
     return false;
   }
 
+  static boolean assertsOn;
+
+  private static boolean testAsserts() {
+    assertsOn = true;
+    return true;
+  }
+
   public static void main(String[] args) throws Throwable {
 
     boolean doFix = false;
@@ -347,6 +354,10 @@
                          "corruption, else 0.\n");
       System.exit(1);
     }
+
+    assert testAsserts();
+    if (!assertsOn)
+      out.println("\nNOTE: testing will be more thorough if you run java with '-ea:org.apache.lucene',
so assertions are enabled");
 
     final String dirName = args[0];
     out.println("\nOpening index @ " + dirName + "\n");



Mime
View raw message