RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v3]
Vyom Tewari
vtewari at openjdk.org
Sun Jul 30 04:58:03 UTC 2023
On Fri, 28 Jul 2023 19:59:15 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Limit native memory allocation and move write loop from the native layer into Java. This change should make the OOME reported in the issue much less likely.
>
> 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 ?.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278508600
More information about the core-libs-dev
mailing list