8200449: ReadAllReadNTransferTo fails occasionally
Summary: Don't pass a non-positive parameter to Random.nextInt(int).
Reviewed-by: chegar
--- a/test/jdk/java/io/ByteArrayInputStream/ReadAllReadNTransferTo.java Sat Mar 24 01:08:35 2018 +0100
+++ b/test/jdk/java/io/ByteArrayInputStream/ReadAllReadNTransferTo.java Thu Mar 29 12:38:47 2018 -0700
@@ -50,8 +50,8 @@
ByteArrayInputStream bais =
new ByteArrayInputStream(buf, position, size);
- int off = random.nextInt(size / 2);
- int len = random.nextInt(size - off);
+ int off = size < 2 ? 0 : random.nextInt(size / 2);
+ int len = size - off < 1 ? 0 : random.nextInt(size - off);
byte[] bN = new byte[off + len];
if (bais.readNBytes(bN, off, len) != len) {