You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2020/07/31 13:11:30 UTC

[lucene-solr] branch branch_8x updated: LUCENE-9440: call FieldInfo.checkConsistency for real (not under assert)

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 2f1ee10  LUCENE-9440: call FieldInfo.checkConsistency for real (not under assert)
2f1ee10 is described below

commit 2f1ee1003b7598558471454ed3a2959bb79fc696
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Thu Jul 30 14:59:55 2020 -0400

    LUCENE-9440: call FieldInfo.checkConsistency for real (not under assert)
---
 lucene/CHANGES.txt                                       |  3 +++
 .../lucene/codecs/lucene50/Lucene50FieldInfosFormat.java |  1 -
 .../lucene/codecs/lucene60/Lucene60FieldInfosFormat.java |  1 -
 .../core/src/java/org/apache/lucene/index/FieldInfo.java | 16 +++++++++-------
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ae5b37b..39eb79a 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -28,6 +28,9 @@ Improvements
 * LUCENE-9416: Fix CheckIndex to print an invalid non-zero norm as
   unsigned long when detecting corruption.
 
+* LUCENE-9440: FieldInfo#checkConsistency called twice from Lucene50(60)FieldInfosFormat#read;
+  Removed the (redundant?) assert and do these checks for real. (Yauheni Putsykovich)
+
 Optimizations
 ---------------------
 
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java
index 0ad0cad..b940092 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java
@@ -149,7 +149,6 @@ public final class Lucene50FieldInfosFormat extends FieldInfosFormat {
           try {
             infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, 
                                      indexOptions, docValuesType, dvGen, attributes, 0, 0, 0, false);
-            infos[i].checkConsistency();
           } catch (IllegalStateException e) {
             throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e);
           }
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java
index aed4c96..ea24491 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60FieldInfosFormat.java
@@ -165,7 +165,6 @@ public final class Lucene60FieldInfosFormat extends FieldInfosFormat {
             infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, 
                                      indexOptions, docValuesType, dvGen, attributes,
                                      pointDataDimensionCount, pointIndexDimensionCount, pointNumBytes, isSoftDeletesField);
-            infos[i].checkConsistency();
           } catch (IllegalStateException e) {
             throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e);
           }
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
index 58b5a66..b8fe341 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
@@ -84,7 +84,7 @@ public final class FieldInfo {
     this.pointIndexDimensionCount = pointIndexDimensionCount;
     this.pointNumBytes = pointNumBytes;
     this.softDeletesField = softDeletesField;
-    assert checkConsistency();
+    this.checkConsistency();
   }
 
   /** 
@@ -179,7 +179,7 @@ public final class FieldInfo {
     if (attributes != null) {
       this.attributes.putAll(attributes);
     }
-    assert checkConsistency();
+    this.checkConsistency();
   }
 
   /** Record that this field is indexed with points, with the
@@ -214,7 +214,7 @@ public final class FieldInfo {
     pointIndexDimensionCount = indexDimensionCount;
     pointNumBytes = numBytes;
 
-    assert checkConsistency();
+    this.checkConsistency();
   }
 
   /** Return point data dimension count */
@@ -241,7 +241,7 @@ public final class FieldInfo {
       throw new IllegalArgumentException("cannot change DocValues type from " + docValuesType + " to " + type + " for field \"" + name + "\"");
     }
     docValuesType = type;
-    assert checkConsistency();
+    this.checkConsistency();
   }
   
   /** Returns IndexOptions for the field, or IndexOptions.NONE if the field is not indexed */
@@ -263,6 +263,7 @@ public final class FieldInfo {
       // cannot store payloads if we don't store positions:
       storePayloads = false;
     }
+    this.checkConsistency();
   }
   
   /**
@@ -276,7 +277,7 @@ public final class FieldInfo {
   /** Sets the docValues generation of this field. */
   void setDocValuesGen(long dvGen) {
     this.dvGen = dvGen;
-    assert checkConsistency();
+    this.checkConsistency();
   }
   
   /**
@@ -289,14 +290,14 @@ public final class FieldInfo {
   
   void setStoreTermVectors() {
     storeTermVector = true;
-    assert checkConsistency();
+    this.checkConsistency();
   }
   
   void setStorePayloads() {
     if (indexOptions != IndexOptions.NONE && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
       storePayloads = true;
     }
-    assert checkConsistency();
+    this.checkConsistency();
   }
 
   /**
@@ -312,6 +313,7 @@ public final class FieldInfo {
       throw new IllegalStateException("cannot omit norms: this field is not indexed");
     }
     omitNorms = true;
+    this.checkConsistency();
   }
   
   /**