Index: lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java =================================================================== --- lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (revision 1525904) +++ lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (working copy) @@ -1432,7 +1432,7 @@ public void testBinaryFixedLengthVsStoredFields() throws Exception { int numIterations = atLeast(1); for (int i = 0; i < numIterations; i++) { - int fixedLength = _TestUtil.nextInt(random(), 1, 10); + int fixedLength = _TestUtil.nextInt(random(), 0, 10); doTestBinaryVsStoredFields(fixedLength, fixedLength); } } @@ -1440,7 +1440,7 @@ public void testBinaryVariableLengthVsStoredFields() throws Exception { int numIterations = atLeast(1); for (int i = 0; i < numIterations; i++) { - doTestBinaryVsStoredFields(1, 10); + doTestBinaryVsStoredFields(0, 10); } } @@ -2958,6 +2958,43 @@ dir.close(); } + // LUCENE-5218 + public void testEmptyBinaryValueOnPageSizes() throws Exception { + // Test larger and larger power-of-two sized values, + // followed by empty string value: + for(int i=0;i<20;i++) { + if (i > 14 && codecAcceptsHugeBinaryValues("field") == false) { + break; + } + Directory dir = newDirectory(); + RandomIndexWriter w = new RandomIndexWriter(random(), dir); + BytesRef bytes = new BytesRef(); + bytes.bytes = new byte[1<= 0: "length=" + length; assert length <= blockSize+1: "length=" + length; + b.length = length; + if (length == 0) { + return; + } final int index = (int) (start >> blockBits); final int offset = (int) (start & blockMask); - b.length = length; if (blockSize - offset >= length) { // Within block b.bytes = blocks[index];