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: 4892246
Votes 0
Synopsis Image I/O breaks when used with Java Web Start
Category java:imageio
Reported Against tiger , 1.4.2_02
Release Fixed
State 11-Closed, duplicate of 4764639, bug
Priority: 2-High
Related Bugs 4764639
Submit Date 17-JUL-2003
Description
The Image I/O PNG reader (and possibly other readers; have not tested) breaks
when used in conjunction with Java Web Start.

The attached test case illustrates the problem.
ClassLoader.getResourceAsStream() is used to fetch an InputStream for a PNG
image contained within the jar. When that InputStream is fed directly into
ImageIO.read(), the reader throws an exception. If a BufferedInputStream is
used to wrap that InputStream, the read succeeds. The read also succeeds if
all of the data in the stream is read manually into a byte array first and a
ByteArrayInputStream is fed into ImageIO.read(). Clearly Image I/O is assuming
something about the buffering behavior of incoming InputStreams, and possibly
something about the semantics of mark/read that might not hold true for
unbuffered input streams.

See comments section for location of test cases.

This bug is being reported against 1.4.2_02 as well as 1.5 because the bug looks
critical and the fix should be backported.
Work Around
Wrap InputStreams in BufferedInputStreams, or read all data into a byte array
and pass in a ByteArrayInputStream to ImageIO.read().
Evaluation
Sounds similar to 4764639, which was already fixed in Tiger.  I'm not able to
reproduce the failure using Java WebStart in the latest Tiger build on
Solaris.  I've contacted the submitter for more info, such as reproducible
platform and build.
  xxxxx@xxxxx   2003-07-17

Received confirmation from submitter that this was actually fixed in 1.5; closing as a duplicate of 4764639.
  xxxxx@xxxxx   2003-07-17
Comments
  
  Include a link with my name & email   

Submitted On 07-SEP-2007
BenGlancy
This IOException behaviour to me comes with PNG and JPEG, GIF is ok and so is BMP.

 InputStream heyyoyu2 = getClass().getResourceAsStream("Renderings/RoomElements/RoomPermutation0.PNG");
 BufferedImage giftest2 = ImageIO.read(abuffered); // Broken IOException

 InputStream heyyoyu2 = getClass().getResourceAsStream("Renderings/RoomElements/RoomPermutation0.BMP");
 BufferedImage giftest2 = ImageIO.read(abuffered); //Works fine

 InputStream heyyoyu2 = getClass().getResourceAsStream("Renderings/RoomElements/RoomPermutation0.GIF");
 BufferedImage giftest2 = ImageIO.read(abuffered); // Works  Fine

getClass().getResourceAsStream("Renderings/RoomElements/RoomPermutation0.JPG");
 BufferedImage giftest2 = ImageIO.read(abuffered); // Broken IOException

This is a serious bug, I've spent all day on it and now not sure how to get a decent but cheap image.


Submitted On 07-SEP-2007
Wrapping it up into a BufferedInputStream didn't help me


Submitted On 17-OCT-2007
BenGlancy
Turns out the above bug was happening during debugging on the latest version of Netbeans. Rolling back to 5.5, the problem has gone.



PLEASE NOTE: JDK6 is formerly known as Project Mustang