From 25ed93dd289b80a757bcc09e7e8daf75abc8c7fb Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Sun, 10 Jul 2016 09:11:32 -0700 Subject: [PATCH] Fix test edge case for random bytes reference iter. Getting an offset to the last byte means we can only stream one byte and then we are done, we can't get another offset after it. --- .../common/bytes/AbstractBytesReferenceTestCase.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/test/java/org/elasticsearch/common/bytes/AbstractBytesReferenceTestCase.java b/core/src/test/java/org/elasticsearch/common/bytes/AbstractBytesReferenceTestCase.java index c521314f92d..103e263ffa6 100644 --- a/core/src/test/java/org/elasticsearch/common/bytes/AbstractBytesReferenceTestCase.java +++ b/core/src/test/java/org/elasticsearch/common/bytes/AbstractBytesReferenceTestCase.java @@ -271,6 +271,9 @@ public abstract class AbstractBytesReferenceTestCase extends ESTestCase { final int offset = randomIntBetween(0, length-1); assertEquals(offset, input.skip(offset)); assertEquals(pbr.get(offset), input.readByte()); + if (offset == length - 1) { + continue; // no more bytes to retrieve! + } final int nextOffset = randomIntBetween(offset, length-2); assertEquals(nextOffset - offset, input.skip(nextOffset - offset)); assertEquals(pbr.get(nextOffset+1), input.readByte()); // +1 for the one byte we read above