[12] RFR JDK-8211266: [TESTBUG] jdk/nio/zipfs/ZipFSTester.java failed intermittently in ZipFSTester.checkRead()

Amy Lu amy.lu at oracle.com
Tue Nov 20 08:37:19 UTC 2018


Please review.

Thanks,
Amy

On 2018/11/12 2:17 PM, Amy Lu wrote:
> Please review this test fix for jdk/nio/zipfs/ZipFSTester.java
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8211266
> webrev: http://cr.openjdk.java.net/~amlu/8211266/webrev.00/
>
> Testcase testStreamChannel fails when the given "bytes" length=0 
> (expected.length=0, and in such case, also sbc.size=0), from checkRead:
>
> 504    static void testStreamChannel() throws Exception {
> ...
> 536                 checkRead(path, bytes);
> }
>
> 435    private static void checkRead(Path path, byte[] expected) 
> throws IOException {
> ...
> 487               int pos = rdm.nextInt((int)sbc.size());
> 488               int len = rdm.nextInt(Math.min(buf.length, 
> expected.length - pos));
>
> This causing
> java.lang.IllegalArgumentException: bound must be positive
> at java.base/java.util.Random.nextInt(Random.java:388)
> at ZipFSTester.checkRead(ZipFSTester.java:487)
> at ZipFSTester.testStreamChannel(ZipFSTester.java:536)
>
> It IS possible that (the given "bytes", byte[] expected) 
> expected.length=0, which is generated by
>     new byte[rdm.nextInt(8192)]
>
> ZipFSTester::checkRead need to take this into account.
>
> Thanks,
> Amy
>
>



More information about the core-libs-dev mailing list