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

Brian Burkhalter bpb at openjdk.org
Tue Jul 25 02:08:42 UTC 2023


On Mon, 24 Jul 2023 12:59:55 GMT, Alan Bateman <alanb 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.
>
> src/java.base/share/classes/java/io/FileOutputStream.java line 366:
> 
>> 364:                 int n = writeBytes(b, off, len, append);
>> 365:                 if (n == -1)
>> 366:                     break;
> 
> Checking if n is -1 doesn't look right here. Isn't return -1 just to keep the compiler happy when an exception is thrown.

This is a copy-paste vestige; will remove.

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

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


More information about the security-dev mailing list