LUCENE-9440: call FieldInfo.checkConsistency for real (not under assert)

This commit is contained in:
Mike McCandless 2020-07-30 14:59:55 -04:00
parent d894a7e8d7
commit cb457571e8
4 changed files with 12 additions and 9 deletions

View File

@ -178,6 +178,9 @@ Improvements
* LUCENE-9416: Fix CheckIndex to print an invalid non-zero norm as * LUCENE-9416: Fix CheckIndex to print an invalid non-zero norm as
unsigned long when detecting corruption. 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 Optimizations
--------------------- ---------------------

View File

@ -149,7 +149,6 @@ public final class Lucene50FieldInfosFormat extends FieldInfosFormat {
try { try {
infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads,
indexOptions, docValuesType, dvGen, attributes, 0, 0, 0, false); indexOptions, docValuesType, dvGen, attributes, 0, 0, 0, false);
infos[i].checkConsistency();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e); throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e);
} }

View File

@ -165,7 +165,6 @@ public final class Lucene60FieldInfosFormat extends FieldInfosFormat {
infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads,
indexOptions, docValuesType, dvGen, attributes, indexOptions, docValuesType, dvGen, attributes,
pointDataDimensionCount, pointIndexDimensionCount, pointNumBytes, isSoftDeletesField); pointDataDimensionCount, pointIndexDimensionCount, pointNumBytes, isSoftDeletesField);
infos[i].checkConsistency();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e); throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e);
} }

View File

@ -84,7 +84,7 @@ public final class FieldInfo {
this.pointIndexDimensionCount = pointIndexDimensionCount; this.pointIndexDimensionCount = pointIndexDimensionCount;
this.pointNumBytes = pointNumBytes; this.pointNumBytes = pointNumBytes;
this.softDeletesField = softDeletesField; this.softDeletesField = softDeletesField;
assert checkConsistency(); this.checkConsistency();
} }
/** /**
@ -179,7 +179,7 @@ public final class FieldInfo {
if (attributes != null) { if (attributes != null) {
this.attributes.putAll(attributes); this.attributes.putAll(attributes);
} }
assert checkConsistency(); this.checkConsistency();
} }
/** Record that this field is indexed with points, with the /** Record that this field is indexed with points, with the
@ -214,7 +214,7 @@ public final class FieldInfo {
pointIndexDimensionCount = indexDimensionCount; pointIndexDimensionCount = indexDimensionCount;
pointNumBytes = numBytes; pointNumBytes = numBytes;
assert checkConsistency(); this.checkConsistency();
} }
/** Return point data dimension count */ /** 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 + "\""); throw new IllegalArgumentException("cannot change DocValues type from " + docValuesType + " to " + type + " for field \"" + name + "\"");
} }
docValuesType = type; docValuesType = type;
assert checkConsistency(); this.checkConsistency();
} }
/** Returns IndexOptions for the field, or IndexOptions.NONE if the field is not indexed */ /** 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: // cannot store payloads if we don't store positions:
storePayloads = false; storePayloads = false;
} }
this.checkConsistency();
} }
/** /**
@ -276,7 +277,7 @@ public final class FieldInfo {
/** Sets the docValues generation of this field. */ /** Sets the docValues generation of this field. */
void setDocValuesGen(long dvGen) { void setDocValuesGen(long dvGen) {
this.dvGen = dvGen; this.dvGen = dvGen;
assert checkConsistency(); this.checkConsistency();
} }
/** /**
@ -289,14 +290,14 @@ public final class FieldInfo {
void setStoreTermVectors() { void setStoreTermVectors() {
storeTermVector = true; storeTermVector = true;
assert checkConsistency(); this.checkConsistency();
} }
void setStorePayloads() { void setStorePayloads() {
if (indexOptions != IndexOptions.NONE && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) { if (indexOptions != IndexOptions.NONE && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
storePayloads = true; 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"); throw new IllegalStateException("cannot omit norms: this field is not indexed");
} }
omitNorms = true; omitNorms = true;
this.checkConsistency();
} }
/** /**