Skip to content

Commit

Permalink
getAudioInputStream was not closing the stream in case of exception c…
Browse files Browse the repository at this point in the history
…ausing the file to remain open and breaking the GetSoundBankSecurityException test which immediately tries to delete it.
  • Loading branch information
wasabii committed Jul 25, 2024
1 parent 1b0aefd commit f195e24
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,23 @@ public AudioFileFormat getAudioFileFormat(File file)

public AudioInputStream getAudioInputStream(URL url)
throws UnsupportedAudioFileException, IOException {
return getAudioInputStream(new BufferedInputStream(url.openStream()));
InputStream stream = url.openStream();
try {
return getAudioInputStream(new BufferedInputStream(stream));
} catch (Exception e) {
stream.close();
throw e;
}
}

public AudioInputStream getAudioInputStream(File file)
throws UnsupportedAudioFileException, IOException {
return getAudioInputStream(new BufferedInputStream(new FileInputStream(
file)));
InputStream stream = new FileInputStream(file);
try {
return getAudioInputStream(new BufferedInputStream(stream));
} catch (Exception e) {
stream.close();
throw e;
}
}
}

0 comments on commit f195e24

Please sign in to comment.