You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Huber (JIRA)" <ji...@apache.org> on 2012/10/22 14:44:12 UTC
[jira] [Commented] (IMAGING-90) ClassCastException: [I cannot be
cast to java.lang.Number in TiffReader.readDirectory(TiffReader.java:239)
and JpegImageParser
[ https://issues.apache.org/jira/browse/IMAGING-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13481338#comment-13481338 ]
Stefan Huber commented on IMAGING-90:
-------------------------------------
Sorry for the late update - I haven't received any notification about the comment. Unfortunately I can not provide a sample image at the moment as they do not belong to me. Sorry about that.
> 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: 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}
> 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