RFR: 8350813: Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError

Harshitha Onkar honkar at openjdk.org
Fri Feb 28 18:50:00 UTC 2025


On Wed, 26 Feb 2025 22:26:48 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

> - Check that the calculated audio data size does not exceed available heap memory before committing to the rendering
> - Add a test case

test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java line 52:

> 50:         }
> 51:         throw new RuntimeException("Test should throw InvalidMidiDataException but it did not.");
> 52:     }

ByteArrayInputStream can be initialized within try-with resources block.

Suggestion:

        try (ByteArrayInputStream bis = new ByteArrayInputStream(midi)) {
            MidiSystem.getSoundbank(bis);
            throw new RuntimeException("Test should throw InvalidMidiDataException" 
                                       + " but it did not.");
        } catch (InvalidMidiDataException imda) {
            System.out.println("Caught InvalidMidiDataException as expected");
        }
    }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23814#discussion_r1975873774


More information about the client-libs-dev mailing list