diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 84e750f6e2880..d2712e268ade2 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -509,12 +509,12 @@ public static int randomInt() { return random().nextInt(); } + /** + * @return a long between 0 and Long.MAX_VALUE (inclusive) chosen uniformly at random. + */ public static long randomNonNegativeLong() { - long randomLong; - do { - randomLong = randomLong(); - } while (randomLong == Long.MIN_VALUE); - return Math.abs(randomLong); + long randomLong = randomLong(); + return randomLong == Long.MIN_VALUE ? 0 : Math.abs(randomLong); } public static float randomFloat() {