RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory [v2]

Brian Burkhalter bpb at openjdk.org
Thu Sep 14 15:57:49 UTC 2023


On Thu, 14 Sep 2023 11:02:42 GMT, Vyom Tewari <vtewari at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8316156: Address reviewer comments
>
> test/jdk/java/nio/channels/Channels/WriteFullyMemorySize.java line 52:
> 
>> 50:             byte[] res = Files.readAllBytes(target);
>> 51:             if (!Arrays.equals(b, res))
>> 52:                 throw new RuntimeException("Arrays are not equal");
> 
> Will this 'throw new RuntimeException("Arrays are not equal");' be ever thrown ?.
> 
> I tested without fix and 'java.lang.OutOfMemoryError' wiil be thrown at line 49(Files.copy) so even in failing case 'RuntimeException' will not be thrown.
> 
> By looking the test name 'WriteFullyMemorySize'  it is not clear to me what it is trying to test. If  you wants to test 'Files.readAllBytes' as well then i will suggest you to  change the name of test or put some comment. It will help the future maintainer of the code.

The `Arrays.equals` is anticipatory. The test is changed in a9af89cff869c441c6dd04f635a4d93e7757f2fa.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326168451


More information about the nio-dev mailing list