Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4910986
Votes 0
Synopsis MIDI file parser breaks up on http connection
Category java:classes_sound
Reported Against tiger
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs
Submit Date 22-AUG-2003
Description




I have an applet that plays a MIDI file.
First I had a small MIDI file with 2 tracks, about 2kb. It ran fine in the
applet, both file: protocol (locally) as http: protocol (remote).

Then I tried to open a larger MIDI file, 5 tracks, 12Kb. I get an exception
when I run the applet using a http url in MSIE6.0, Java Plug-in Version
1.4.2:
IO exception:

java.io.EOFException
 at com.sun.media.sound.SMFParser.nextTrack(Unknown Source)
 at com.sun.media.sound.StandardMidiFileReader.getSequence(Unknown Source)
 at com.sun.media.sound.StandardMidiFileReader.getSequence(Unknown Source)

----

Now I use
result = MidiSystem.getSequence(new BufferedInputStream(url.openStream()));

(The BufferedInputStream is necessary for the required mark and reset operations.)

instead of
result = MidiSystem.getSequence(url);

This solved my problem.


======================================================================
Work Around
Read the URL stream into a byte array, create an ByteArrayInputStream from the array, and then load the sequence from that stream.
  xxxxx@xxxxx   2003-12-11
Evaluation
  xxxxx@xxxxx   2003-08-22
	The MIDI parser doesn't take into account that InputStream.read(byte[]) may read less bytes than requested without having reached the end of stream. For http connections from URLs, the parser chokes on this assumption and aborts parsing of the MIDI file. The solution is to use DataInputStream.readFully().
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang