Stefan Huber created IMAGING-90:
-----------------------------------

             Summary: ClassCastException: [I cannot be cast to java.lang.Number 
in TiffReader.readDirectory(TiffReader.java:239)
                 Key: IMAGING-90
                 URL: https://issues.apache.org/jira/browse/IMAGING-90
             Project: Commons Imaging
          Issue Type: Bug
          Components: Format: JPEG
    Affects Versions: 1.0
         Environment: jdk 1.6.0_33
            Reporter: Stefan Huber


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.
{code}
int subDirectoryOffset = ((Number) entry.getValue())
                            .intValue();
{code}

This may occur if the entry does not have any actual value. This is the entry 
shown by the debugger:

{code}
 40965 (0xa005: InteropOffset):  (0 Long)
{code}

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:
{code}
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)
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to