Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4834374

MIDI file reader fails for some MIDI files

XMLWordPrintable

    • 05
    • generic, x86
    • generic, windows_xp
    • Verified

        When doing stress tests with 1200 random MIDI files from the Internet, 75 failed in 1.4.2beta. Furthermore, the exceptions have a "null" message. This behavior is different from 1.4.1.

        Examples (attached to this bug):
        - bewitd_a.mid: threw "could not get sequence from file" in 1.4.1, but "null" in 1.4.2

        - bitedust.mid: throw IOException "Stream Read Error" in 1.4.1, but "null" in 1.4.2

        - secret.mid: fails in all 1.4.x (along with 73 others)

        - yourtime.mid: fails in 1.4.2 but not in 1.4.1

        - bohem_al.mid: fails in 1.4.1 and 1.4.2, but loads OK in 1.4.0.

        ------------
        Test program:

        import java.io.*;
        import javax.sound.midi.*;

        public class MidiFileTester {
            
            // 0: test with MidiSystem.getSequence(File)
            // 1: test with MidiSystem.getSequence(InputStream)
            // 2: test with Sequencer.setSequence(InputStream)
            static int TEST_METHOD=0;
            
            public static void main(String[] args) throws Exception {
        if (args.length == 0) {
        System.out.println("No parameter specified");
        System.exit(1);
        }
        int total=0; int succ=0;
        long startTime=System.currentTimeMillis();

        switch (TEST_METHOD) {
        case 0: System.out.println("Test using "
        +"MidiSystem.getSequence(File)"); break;
        case 1: System.out.println("Test using "
        +"MidiSystem.getSequence(InputStream)"); break;
        case 2: System.out.println("Test using "
        +"Sequencer.setSequence(InputStream)"); break;
        }
            
        Sequencer s = null;
        if (TEST_METHOD==2) {
        s = MidiSystem.getSequencer();
        s.open();
        }

        for (int i=0; i<args.length; i++) {
        String filename = args[i];
        File midiFile = new File(filename);
        if (!midiFile.exists()) {
        continue;
        }
        System.out.print(""+i+": "+filename+"...");
        total++;
        try {
        //MidiFileFormat mff = MidiSystem.getMidiFileFormat(midiFile);
        if (TEST_METHOD == 0) {
        Sequence seq = MidiSystem.getSequence(midiFile);
        }
        if ((TEST_METHOD == 1) || (TEST_METHOD == 2)) {
        BufferedInputStream bis =
        new BufferedInputStream(new FileInputStream(midiFile));
        if (TEST_METHOD == 1) {
        Sequence seq = MidiSystem.getSequence(bis);
        } else {
        s.setSequence(bis);
        }
        }
        succ++;
        System.out.println("OK");
        } catch (Exception e) {
        System.out.println("FAILED:"+e.toString());
        }
        }
        if (TEST_METHOD==2) {
        s.close();
        }
        System.out.println(""+succ+"/"+total+" successful."
        +" Failed:"+(total-succ));
        long duration=System.currentTimeMillis()-startTime;
        System.out.println("Duration: "+(duration / 1000)+"s "
        +(duration % 1000)+"ms");
        System.exit(0);
            }
        }

              fbomerssunw Florian Bomers (Inactive)
              fbomerssunw Florian Bomers (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: