lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1662949 - /lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
Date Sat, 28 Feb 2015 15:28:01 GMT
Author: mikemccand
Date: Sat Feb 28 15:28:01 2015
New Revision: 1662949

URL: http://svn.apache.org/r1662949
Log:
make SimpleText's checkIntegrity more robust so it's not fooled if you index the string END

Modified:
    lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java

Modified: lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java?rev=1662949&r1=1662948&r2=1662949&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
Sat Feb 28 15:28:01 2015
@@ -526,10 +526,16 @@ class SimpleTextDocValuesReader extends
     BytesRefBuilder scratch = new BytesRefBuilder();
     IndexInput clone = data.clone();
     clone.seek(0);
+    // checksum is fixed-width encoded with 20 bytes, plus 1 byte for newline (the space
is included in SimpleTextUtil.CHECKSUM):
+    long footerStartPos = data.length() - (SimpleTextUtil.CHECKSUM.length + 21);
     ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
-    while(true) {
+    while (true) {
       SimpleTextUtil.readLine(input, scratch);
-      if (scratch.get().equals(END)) {
+      if (input.getFilePointer() >= footerStartPos) {
+        // Make sure we landed at precisely the right location:
+        if (input.getFilePointer() != footerStartPos) {
+          throw new CorruptIndexException("SimpleText failure: footer does not start at expected
position current=" + input.getFilePointer() + " vs expected=" + footerStartPos, input);
+        }
         SimpleTextUtil.checkFooter(input);
         break;
       }



Mime
View raw message