JDK-4834374 : MIDI file reader fails for some MIDI files
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.4.1,1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2003-03-19
  • Updated: 2004-04-28
  • Resolved: 2003-08-02
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.
Other
1.4.2_05 05Fixed
Related Reports
Duplicate :  
Relates :  
Description
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);
    }
}


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_05 generic tiger FIXED IN: 1.4.2_05 tiger INTEGRATED IN: 1.4.2_05 tiger tiger-b14 VERIFIED IN: 1.4.2_05
14-06-2004

EVALUATION ###@###.### 2003-03-18 Should get fixed for tiger. ###@###.### 2004-01-26 In response to the web comments: 1) This bug is fixed in tiger (i.e. 1.5.0). When a bug is marked "fixed" online, it doesn't mean that the fix is available to the public yet. An alpha version was made available in Dec 2003, and a beta version will follow shortly. 2) This bug will also be fixed in 1.4.2_05 3) Bug 4883425 is fixed along with this bug (therefore "duplicate"). 4) Both bugs are a vulnerability to malformed MIDI files. They do not affect "normal" operation of Java Sound.
11-06-2004

WORK AROUND instead of Sequence s = MidiSystem.getSequence() use Sequencer s = MidiSystem.getSequencer(); s.open(); s.setSequence(InputStream); However, this will crash the sequencer sometimes (see bug 4795377).
11-06-2004

PUBLIC COMMENTS MIDI file reader fails for some MIDI files
10-06-2004