提交 8dd1882f 编写于 作者: B bpb

8189775: java/nio/channels/FileChannel/directio/ReadDirect.java failed with NumberFormatException

Summary: Clamp the offset so the scattering read remains within the channel.
Reviewed-by: rriggs
上级 b3fdcea5
......@@ -177,7 +177,12 @@ public class ReadDirect {
}
}
randomNumber = generator.nextInt(100);
// The size of the test FileChannel is 100*charsPerGroup.
// As the channel bytes will be scattered into two buffers
// each of size charsPerGroup, the offset cannot be greater
// than 98*charsPerGroup, so the value of randomNumber must
// be in the range [0,98], i.e., 0 <= randomNumber < 99.
randomNumber = generator.nextInt(99);
long offset = randomNumber * charsPerGroup;
fc.position(offset);
fc.read(dests, 1, 2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册