RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v3]
Brian Burkhalter
bpb at openjdk.org
Wed Aug 2 22:51:36 UTC 2023
On Sun, 30 Jul 2023 13:06:36 GMT, Alan Bateman <alanb 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/classes/java/io/FileOutputStream.java line 347:
>
>> 345: pos += n;
>> 346: remaining -= n;
>> 347: } while (remaining > 0);
>
> Long standing behavior is that write is a no-op with len is 0, meaning you can do while here (no need to change it to do-while). Same thing in RAF.
So changed in cdb8455ccbd1db49d272e867b16a14eb72b41a7b.
> src/java.base/share/native/libjava/io_util.c line 160:
>
>> 158: }
>> 159:
>> 160: if (outOfBounds(env, off, len, bytes)) {
>
> I assume the IS_NULL and outOfBounds checking in both readBytes and writeBytes are redundant now.
Right. Removed in cdb8455ccbd1db49d272e867b16a14eb72b41a7b.
> src/java.base/share/native/libjava/io_util.c line 183:
>
>> 181: if (fd == -1) {
>> 182: JNU_ThrowIOException(env, "Stream Closed");
>> 183: nwritten = -1;
>
> nwritten is initialized to -1.
Removed in cdb8455ccbd1db49d272e867b16a14eb72b41a7b.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1279618127
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1279617787
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1279618406
More information about the core-libs-dev
mailing list