commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damjan Jovanovic (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (IMAGING-90) ClassCastException: [I cannot be cast to java.lang.Number in TiffReader.readDirectory(TiffReader.java:239) and JpegImageParser
Date Sun, 02 Dec 2012 10:01:58 GMT

     [ https://issues.apache.org/jira/browse/IMAGING-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Damjan Jovanovic resolved IMAGING-90.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0

Fixed by allowing for non-1 tag lengths in non-strict mode (and then ignoring those tags);
getMetadata() should now work, and other methods may require explicitly setting strict mode
to off. Thank you for your bug report.

                
> ClassCastException: [I cannot be cast to java.lang.Number in TiffReader.readDirectory(TiffReader.java:239)
and JpegImageParser
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 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: st.h
>             Fix For: 1.0
>
>
> 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}
> The same issue applies to similar uses of TiffField, for instance JpegImageParser around
line 676.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message