RFR for bug JDK-8030690 TEST_BUG java/nio/Buffer/Chars.java fails intermittently
Eric Wang
yiming.wang at oracle.com
Thu Dec 19 00:01:10 PST 2013
Hi Everyone,
I'm working on the bug https://bugs.openjdk.java.net/browse/JDK-8030690.
The test failed due to there's a logic fault in randomizeRange(), if
cb.capacity() returns 1 then mid = cb.capacity() >>> 1 which is 0. it
causes Random.nextInt(0) throws the IllegalArgumentException.
So the suggested fix is to update the randomizeRange() like below.
static CharBuffer randomizeRange(CharBuffer cb) {
int mid = cb.capacity() >>> 1;
int start = RAND.nextInt(mid + 1); // from 0 to mid
int end = mid + RAND.nextInt(cb.capacity() - mid + 1); // from
mid to capacity.
cb.position(start);
cb.limit(end);
return cb;
}
Please let me know if you have any comment. The webrev will be sent soon.
Thanks,
Eric
More information about the nio-dev
mailing list