Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-alpha1
-
None
-
jdk 1.6.0_33
Description
Version 1.0 rc2. (Checked the trunk, but couldn't find any commits concerning this issue)
When calling Imaging.getImageInfo on certain (in this case jpeg) images, there might be a ClassCastException in TiffReader:239 if the entry is not a Number.
int subDirectoryOffset = ((Number) entry.getValue()) .intValue();
This may occur if the entry does not have any actual value. This is the entry shown by the debugger:
40965 (0xa005: InteropOffset): (0 Long)
A quick solution to this problem might be to check if entry.getValue() could be cast to a Number before doing so. Probably there is a more elegant way, but I haven't had the time to analyze this thoroughly.
Here is the stack trace:
Caused by: java.lang.ClassCastException: [I cannot be cast to java.lang.Number at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:239) at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:253) at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:103) at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectories(TiffReader.java:95) at org.apache.commons.imaging.formats.tiff.TiffReader.read(TiffReader.java:419) at org.apache.commons.imaging.formats.tiff.TiffReader.readContents(TiffReader.java:410) at org.apache.commons.imaging.formats.tiff.TiffImageParser.getMetadata(TiffImageParser.java:132) at org.apache.commons.imaging.ImageParser.getMetadata(ImageParser.java:203) at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getExifMetadata(JpegImageParser.java:335) at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getMetadata(JpegImageParser.java:295) at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getImageInfo(JpegImageParser.java:668) at org.apache.commons.imaging.Imaging.getImageInfo(Imaging.java:683) at org.apache.commons.imaging.Imaging.getImageInfo(Imaging.java:615)
The same issue applies to similar uses of TiffField, for instance JpegImageParser around line 676.