Fix Broken Math in S3 Retries Tests (#54952) (#54972)

If we run into `length == 0` we trip an assertion in `randomIntBetween(0, length -1)`.
This commit is contained in:
Armin Braun 2020-04-08 20:32:21 +02:00 committed by GitHub
parent 964cf565c9
commit 411dc2f607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -551,7 +551,7 @@ public class S3BlobContainerRetriesTests extends ESTestCase {
} }
exchange.getResponseHeaders().add("Content-Type", "text/plain; charset=utf-8"); exchange.getResponseHeaders().add("Content-Type", "text/plain; charset=utf-8");
exchange.sendResponseHeaders(HttpStatus.SC_OK, length); exchange.sendResponseHeaders(HttpStatus.SC_OK, length);
final int bytesToSend = randomIntBetween(0, length - 1); final int bytesToSend = length == 0 ? 0 : randomIntBetween(0, length - 1);
if (bytesToSend > 0) { if (bytesToSend > 0) {
exchange.getResponseBody().write(bytes, rangeStart, bytesToSend); exchange.getResponseBody().write(bytes, rangeStart, bytesToSend);
} }