ShimejiEE-cross-platform icon indicating copy to clipboard operation
ShimejiEE-cross-platform copied to clipboard

SoundLoader doesn't close the AudioInputStream

Open WALLE1Doctor1Who opened this issue 7 months ago • 1 comments

In the createClipFrom method in the SoundLoader class, the AudioInputStream is not closed by the end of the method. I'm not sure if this was done intentionally or accidentally, but this results in the sound file remaining open and accessed by the program. Putting it in a try-with-resources seems to fix the error that was popping up when attempting to compile (the error being that it kept failing to delete a temporary file, likely due to the test still accessing it), but I do not know if that may break the audio as I don't know how to trigger a sound effect to play in program. I have included two screenshots, one where the code is unmodified and my suggested correction. I have also included the error log that the unmodified code produces.

Error log produced by maven from tests: com.group_finity.mascot.sound.SoundLoaderTest.txt

Unmodified code that doesn't compile: image

My suggested correction that does compile without errors: image

WALLE1Doctor1Who avatar Jul 09 '24 05:07 WALLE1Doctor1Who