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 2014/10/31 17:32:31 UTC
svn commit: r1635807 - in
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index:
DefaultIndexingChain.java FieldInfo.java
Author: mikemccand
Date: Fri Oct 31 16:32:30 2014
New Revision: 1635807
URL: http://svn.apache.org/r1635807
Log:
LUCENE-6039: a few more null checks
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java?rev=1635807&r1=1635806&r2=1635807&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java Fri Oct 31 16:32:30 2014
@@ -379,6 +379,9 @@ final class DefaultIndexingChain extends
}
private static void verifyFieldType(String name, IndexableFieldType ft) {
+ if (ft.indexOptions() == null) {
+ throw new NullPointerException("IndexOptions must not be null (field: \"" + name + "\")");
+ }
if (ft.indexOptions() == IndexOptions.NO) {
if (ft.storeTermVectors()) {
throw new IllegalArgumentException("cannot store term vectors "
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java?rev=1635807&r1=1635806&r2=1635807&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java Fri Oct 31 16:32:30 2014
@@ -34,7 +34,7 @@ public final class FieldInfo {
/** Internal field number */
public final int number;
- private DocValuesType docValueType = DocValuesType.NO;
+ private DocValuesType docValuesType = DocValuesType.NO;
// True if any document indexed term vectors
private boolean storeTermVector;
@@ -56,14 +56,14 @@ public final class FieldInfo {
boolean storePayloads, IndexOptions indexOptions, DocValuesType docValues,
long dvGen, Map<String,String> attributes) {
if (docValues == null) {
- throw new NullPointerException("DocValuesType cannot be null");
+ throw new NullPointerException("DocValuesType cannot be null (field: \"" + name + "\")");
}
if (indexOptions == null) {
- throw new NullPointerException("IndexOptions cannot be null");
+ throw new NullPointerException("IndexOptions cannot be null (field: \"" + name + "\")");
}
this.name = name;
this.number = number;
- this.docValueType = docValues;
+ this.docValuesType = docValues;
this.indexOptions = indexOptions;
if (indexOptions != IndexOptions.NO) {
this.storeTermVector = storeTermVector;
@@ -101,7 +101,7 @@ public final class FieldInfo {
}
}
- if (dvGen != -1 && docValueType == null) {
+ if (dvGen != -1 && docValuesType == DocValuesType.NO) {
throw new IllegalStateException("field '" + name + "' cannot have a docvalues update generation without having docvalues");
}
@@ -115,7 +115,7 @@ public final class FieldInfo {
// should only be called by FieldInfos#addOrUpdate
void update(boolean storeTermVector, boolean omitNorms, boolean storePayloads, IndexOptions indexOptions) {
if (indexOptions == null) {
- throw new NullPointerException("IndexOptions cannot be null");
+ throw new NullPointerException("IndexOptions cannot be null (field: \"" + name + "\")");
}
//System.out.println("FI.update field=" + name + " indexed=" + indexed + " omitNorms=" + omitNorms + " this.omitNorms=" + this.omitNorms);
if (this.indexOptions != indexOptions) {
@@ -144,10 +144,13 @@ public final class FieldInfo {
}
void setDocValuesType(DocValuesType type) {
- if (docValueType != DocValuesType.NO && docValueType != type) {
- throw new IllegalArgumentException("cannot change DocValues type from " + docValueType + " to " + type + " for field \"" + name + "\"");
+ if (type == null) {
+ throw new NullPointerException("DocValuesType cannot be null (field: \"" + name + "\")");
}
- docValueType = type;
+ if (docValuesType != DocValuesType.NO && docValuesType != type) {
+ throw new IllegalArgumentException("cannot change DocValues type from " + docValuesType + " to " + type + " for field \"" + name + "\"");
+ }
+ docValuesType = type;
assert checkConsistency();
}
@@ -160,7 +163,7 @@ public final class FieldInfo {
* Returns true if this field has any docValues.
*/
public boolean hasDocValues() {
- return docValueType != DocValuesType.NO;
+ return docValuesType != DocValuesType.NO;
}
/**
@@ -168,7 +171,7 @@ public final class FieldInfo {
* {@code DocValuesType.NO} if the field has no docvalues.
*/
public DocValuesType getDocValuesType() {
- return docValueType;
+ return docValuesType;
}
/** Sets the docValues generation of this field. */