RFR: 8264821: DirectIOTest fails on a system with large block size

Alan Bateman alanb at openjdk.java.net
Wed Apr 14 15:43:38 UTC 2021


On Wed, 14 Apr 2021 01:37:19 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Please review this request to clean up a test. The main change is to ensure that the capacity passed to `ByteBuffer.allocateDirect()` is large enough that when `alignedSlice()` is called on the new buffer, it creates an aligned buffer which does not have size zero due due to position rounding resulting in out-of-bound values. Other changes in the test are cleanup.

test/jdk/java/nio/channels/FileChannel/directio/DirectIOTest.java line 72:

> 70:     private static int testRead(Path p) throws Exception {
> 71:         try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) {
> 72:             int bs = (int)blockSize;

It might be a bit clearer to pass the blockSize to the testRead and testWrite methods.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3482


More information about the nio-dev mailing list