RFR: 8278166: java/nio/channels/Channels/TransferTo.java timed out [v2]

Alan Bateman alanb at openjdk.java.net
Mon Dec 6 18:03:13 UTC 2021


On Mon, 6 Dec 2021 17:48:42 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> In the `testMoreThanTwoGB()` sub-test, only fill the last section of the file with random data in order to reduce test execution time.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - 8278166: Replace RandomAccessFile with FileChannel.open + FileChannel.position(long)
>  - Merge
>  - 8278166: java/nio/channels/Channels/TransferTo.java timed out

This is much better, just some minor comments and I think we are good to go. There are probably other tests with large files that could benefit from the same thing.

test/jdk/java/nio/channels/Channels/TransferTo.java line 160:

> 158:     public void testMoreThanTwoGB() throws IOException {
> 159:         Path sourceFile = CWD.resolve(Path.of(String.format("test3GBSource%s.tmp",
> 160:             String.valueOf(RND.nextInt(Integer.MAX_VALUE)))));

The Path.of isn't needed here as there is an overload of resolve that takes a String. For readability then it might be simpler to create the file name (as a String) on its own line.

test/jdk/java/nio/channels/Channels/TransferTo.java line 170:

> 168:                 // create the file with a hint to be sparse
> 169:                 try (FileChannel fc = FileChannel.open(sourceFile, CREATE_NEW,
> 170:                     SPARSE, WRITE, APPEND);) {

might be a bit more readable to not split this line.

test/jdk/java/nio/channels/Channels/TransferTo.java line 178:

> 176:                     for (int i = 0; i < nw; i++) {
> 177:                         ByteBuffer src =
> 178:                             ByteBuffer.wrap(createRandomBytes(BYTES_PER_WRITE, 0));

Probably not worth splitting this line either.

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

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


More information about the nio-dev mailing list