RFR: 8324657: Intermittent OOME on exception message create
Sergey Bylokhov
serb at openjdk.org
Thu Jan 25 00:20:29 UTC 2024
On Mon, 22 Jan 2024 20:52:32 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> When an exception handler for an OutOfMemoryError uses string concatenation to compose an exception message, the invoke dynamic string format implementation may itself exhaust memory, preventing the exception from being handled.
> Explicit use of String.concat() call can improve exception handling.
>
> Writing a test of the exact failure condition has proved challenging due to the unpredictable state of memory when OOME occurs. The replacement of "+" with String.concat() is simple and direct.
src/java.base/share/classes/java/io/ObjectInputStream.java line 2016:
> 2014: // Generate an InvalidObjectException for an OutOfMemoryError
> 2015: // Use String.concat() to avoid string formatting invoke dynamic
> 2016: private static InvalidObjectException genInvalidObjectException(OutOfMemoryError oome, String[] ifaces) {
Isn't this new line is too long? It seems most of the file uses 80 chars per line.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17522#discussion_r1465700346
More information about the core-libs-dev
mailing list