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


Reply via email to