lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r807216 - /lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
Date Mon, 24 Aug 2009 13:50:10 GMT
Author: uschindler
Date: Mon Aug 24 13:50:10 2009
New Revision: 807216

URL: http://svn.apache.org/viewvc?rev=807216&view=rev
Log:
Prevent a NPE, when OffsetAttribute is not available.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java?rev=807216&r1=807215&r2=807216&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
(original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
Mon Aug 24 13:50:10 2009
@@ -211,8 +211,12 @@
     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);



Mime
View raw message