8200449: ReadAllReadNTransferTo fails occasionally
Don't pass a non-positive parameter to Random.nextInt(int). Reviewed-by: chegar
This commit is contained in:
parent
aa69f8c75c
commit
dee3c23d5b
@ -50,8 +50,8 @@ public class ReadAllReadNTransferTo {
|
||||
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user