JDK-6410864 : ImageReader-s returned from ImageIO.getImageReaders() doesn't follow spec
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-04-10
  • Updated: 2011-01-19
  • Resolved: 2006-04-11
Related Reports
Duplicate :  
Relates :  
Description
ImageReader instances returned by ImageIO.getImageReaders() don't correctly follow spec for the following methods: getAspectRatio(), getRawImageType().

There are problems with throwing of IndexOutOfBoundsException from these methods.
1) javax.imageio.PNGImageReader.getAspectRatio() doesn't throw IndexOutOfBoundsException for incorrect index
Please find in the attachment the file GetAspectRatioTest.java to verify this behavior.
Output is following:
ImageReader: javax.imageio.PNGImageReader@a440b9
Num of Images: 1
getAspectRatio(0) = 1.0294118
getAspectRatio(-2147483648) didn't throw IndexOutOfBoundsException
getAspectRatio(-2147483648) = 1.0294118
getAspectRatio(-1) didn't throw IndexOutOfBoundsException
getAspectRatio(-1) = 1.0294118
getAspectRatio(10) didn't throw IndexOutOfBoundsException
getAspectRatio(10) = 1.0294118
getAspectRatio(2147483647) didn't throw IndexOutOfBoundsException
getAspectRatio(2147483647) = 1.0294118
Failed

2) javax.imageio.JPEGImageReader.getRawImageType() doesn't throw IndexOutOfBoundsException for index = -1.
Please find in the attachment corresponding example GetRawImageTypeTest.java.
Output is: 
ImageReader: javax.imageio.JPEGImageReader@c3e31
getMinIndex() = 0
getRawImageType(-2147483648): OK
getRawImageType(-1) didn't throw IndexOutOfBoundsException
getRawImageType(-1) = null
getRawImageType(10): OK
getRawImageType(2147483647): OK
Failed

Comments
EVALUATION This bug is related to two different problems: 1. PNGImageReader.getAspectRatio() does not throw IndexOutOfBoundsException if the supplied index is out of bounds. This one was fixed as part of fix for 4892630 (PNG Image Reader does not validate the image index passed to some of the methods) which was integrated into 6.0b62. 2. JPEGImageReader.getRawImageType() does not throw IndexOutOfBoundsException if the supplied index is out of bounds. This problem is duplicate of existing bug 4892631 (JPEG ImageReader does not validate the image indices with respect to Min Index) because same image index validation procedure is used as for getRawImageType() as for mentioned in the 4892631 methods getWidth(), getHeight(), read() and getAspectRatio().
11-04-2006