[TEST] Fix offsets in BaseXContentTestCase.testBinaryValueWithOffsetLength

The max value for randomIntBetween is inclusive, so we should use byte array length minus one to avoid an AIOB exception.
This commit is contained in:
Nicholas Knize 2016-09-09 11:47:37 -05:00
parent 55a2f26b21
commit 297fc8373d

@ -295,8 +295,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
assertResult("{'binary':null}", () -> builder().startObject().field("binary").value(null, 0, 0).endObject());
final byte[] randomBytes = randomBytes();
final int offset = randomIntBetween(0, randomBytes.length);
final int length = randomIntBetween(1, Math.max(1, randomBytes.length - offset));
final int offset = randomIntBetween(0, randomBytes.length - 1);
final int length = randomIntBetween(1, Math.max(1, randomBytes.length - offset - 1));
XContentBuilder builder = builder().startObject();
if (randomBoolean()) {