Skip to content

SoundLoader doesn't close the AudioInputStream #13

@Mosblinker

Description

@Mosblinker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions