Prevent a NPE, when OffsetAttribute is not available.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@807216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-08-24 13:50:10 +00:00
parent 90ba4496ef
commit 5cd31d4683
1 changed files with 6 additions and 2 deletions

View File

@ -211,8 +211,12 @@ final class TermVectorsTermsWriterPerField extends TermsHashConsumerPerField {
p.freq = 1; p.freq = 1;
if (doVectorOffsets) { if (doVectorOffsets) {
int startOffset = fieldState.offset + offsetAttribute.startOffset();; int startOffset = fieldState.offset;
int endOffset = fieldState.offset + offsetAttribute.endOffset(); int endOffset = fieldState.offset;
if (offsetAttribute != null) {
startOffset += offsetAttribute.startOffset();
endOffset += offsetAttribute.endOffset();
}
termsHashPerField.writeVInt(1, startOffset); termsHashPerField.writeVInt(1, startOffset);
termsHashPerField.writeVInt(1, endOffset - startOffset); termsHashPerField.writeVInt(1, endOffset - startOffset);