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