From 5cd31d4683b61445a38446e1d66e6bb2c3c3b76f Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Mon, 24 Aug 2009 13:50:10 +0000 Subject: [PATCH] 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 --- .../lucene/index/TermVectorsTermsWriterPerField.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java b/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java index c7bab18633e..c3d0b942416 100644 --- a/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java +++ b/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java @@ -211,8 +211,12 @@ final class TermVectorsTermsWriterPerField extends TermsHashConsumerPerField { p.freq = 1; if (doVectorOffsets) { - int startOffset = fieldState.offset + offsetAttribute.startOffset();; - int endOffset = fieldState.offset + offsetAttribute.endOffset(); + int startOffset = fieldState.offset; + int endOffset = fieldState.offset; + if (offsetAttribute != null) { + startOffset += offsetAttribute.startOffset(); + endOffset += offsetAttribute.endOffset(); + } termsHashPerField.writeVInt(1, startOffset); termsHashPerField.writeVInt(1, endOffset - startOffset);