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/30 19:00:18 UTC
[lucene-solr] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new cb45757 LUCENE-9440: call FieldInfo.checkConsistency for real (not under assert)
cb45757 is described below
commit cb457571e83761e2fe6f9a2e54c4a1ada1e54f5f
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 52a414d..4d15969 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -178,6 +178,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 384dbc2..f8368bc 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 6ab81cd..3b97c26 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();
}
/**