JDK-4910986 : MIDI file parser breaks up on http connection
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-08-22
  • Updated: 2003-08-25
  • Resolved: 2003-08-25
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
5.0 tigerFixed
Description

Name: fb126949			Date: 08/22/2003


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.


======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b17
14-06-2004

EVALUATION ###@###.### 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().
11-06-2004

PUBLIC COMMENTS MIDI file parser breaks up on http connection
10-06-2004

WORK AROUND Read the URL stream into a byte array, create an ByteArrayInputStream from the array, and then load the sequence from that stream. ###@###.### 2003-12-11
11-12-2003