RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v3]

Alan Bateman alanb at openjdk.org
Sun Jul 30 12:51:03 UTC 2023


On Sun, 30 Jul 2023 04:54:32 GMT, Vyom Tewari <vtewari at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   6478546: Move buffer clamping up to Java layer; correct read behavior to match legacy
>
> src/java.base/share/native/libjava/io_util.c line 171:
> 
>> 169:         if (buf == NULL) {
>> 170:             JNU_ThrowOutOfMemoryError(env, NULL);
>> 171:             return 0;
> 
> why we are returning '0' here ? I can see, it is consistence with 'readBytes'  in case of OOM error we are returning 0 and other exceptions we are returning -1. Can you please help me understand if there is any specific reason for returning 0 in case of OOM ?.

This a JNI function returning with a pending exception so the return value doesn't matter.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278562919


More information about the core-libs-dev mailing list