RFR: 8316156: ByteArrayInputStream.transferTo causes MaxDirectMemorySize overflow [v6]

Paul Wagland duke at openjdk.org
Thu Sep 28 12:12:37 UTC 2023


On Tue, 19 Sep 2023 20:03:57 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> `ByteArrayInputStream.transferTo` invoked with an `OutputStream` parameter which delegates to a `FileChannel` throws an `OutOfMemoryError` if the length of the `byte[]` wrapped by the `ByteArrayInputStream` exceeds `MaxDirectMemorySize`. This is because `FileChannel.write` uses `IOUtil.write` which creates a temporary direct buffer for writing. If the `byte[]` length is larger than `MaxDirectMemorySize`, then the temporary direct buffer allocation fails with an `OutOfMemoryError`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8316156: Revert BufferedInputStream changes; update test

@blpb / @AlanBateman : Do you know if this will this also be released to Java 17 and/or Java 21 service packs?

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

PR Comment: https://git.openjdk.org/jdk/pull/15733#issuecomment-1739017905


More information about the nio-dev mailing list