JDK-4629810 : MidiSystem.getSoundbank() throws unexpected IOException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_1
  • CPU: generic,sparc
  • Submitted: 2002-01-29
  • Updated: 2004-03-12
  • Resolved: 2003-10-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
5.0 b26Fixed
Related Reports
Duplicate :  
Name: vtR10009			Date: 01/29/2002

  API spec for the method javax.sound.midi.MidiSystem.getSoundbank(File) 
  InvalidMidiDataException - if the File does not point to valid MIDI soundbank
data recognized  by the system
  IOException - if an I/O error occurred when loading the soundbank".

But this method throws unexpected IOException instead of
InvalidMidiDataException for invalid soundBank files.
This bug causes failure of new JCK test:
To reproduce the bug run the following test with JDK 1.4.0-rc-b90 build:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;
import java.io.*;

public class test{
    public static void main(String args[])
        String fName = "invalid.mid";
        String testdir = args[0];
        boolean failed = false;

        try {
            File file = new File(testdir, fName);
            Soundbank sBank = MidiSystem.getSoundbank(file);
            System.err.println("InvalidMidiDataException was not thrown!");
            failed = true;
        } catch (InvalidMidiDataException invMidiEx) {
        } catch (IOException ioEx) {
            System.err.println("Unexpected IOException was caught!");
            failed = true;
        if( failed ) {
            System.err.println("Test failed!");
        } else {
$ javac test.java
$ java test .
Unexpected IOException was caught!
mark/reset not supported
java.io.IOException: mark/reset not supported
        at java.io.InputStream.reset(InputStream.java:329)
        at com.sun.media.sound.HsbParser.getSoundbank(HsbParser.java:66)
        at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:287)
        at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:346)
        at test.main(test.java:12)
Test failed!
^C$ cat invalid.mid 
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
$ java -version
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b90)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b90, mixed mode)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b26 tiger-beta VERIFIED IN: tiger-b41

EVALUATION ###@###.### 2002-01-29 The internal implementation constructs a FileInputStream from the passed File descriptor. It then reads the entire file and when it discovers that it's not a valid soundbank, it tries to reset the stream. This fails. The fix will be to construct a stream that reads from the file and which can be reset. Also, in a second step, it should be prevented that the implementation reads the entire soundbank file before attempting to parse it. ###@###.### 2002-10-31 No resources in mantis time frame to fix this bug. Committing to tiger.