Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 38015DB58 for ; Sat, 1 Sep 2012 10:31:17 +0000 (UTC) Received: (qmail 14405 invoked by uid 500); 1 Sep 2012 10:31:16 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 13868 invoked by uid 500); 1 Sep 2012 10:31:09 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 13811 invoked by uid 99); 1 Sep 2012 10:31:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 10:31:08 +0000 Date: Sat, 1 Sep 2012 21:31:07 +1100 (NCT) From: "Damjan Jovanovic (JIRA)" To: issues@commons.apache.org Message-ID: <735043980.26582.1346495468030.JavaMail.jiratomcat@arcas> In-Reply-To: <1326377926.35357.1345556258568.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (IMAGING-90) ClassCastException: [I cannot be cast to java.lang.Number in TiffReader.readDirectory(TiffReader.java:239) and JpegImageParser MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/IMAGING-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13446643#comment-13446643 ] Damjan Jovanovic commented on IMAGING-90: ----------------------------------------- Can I please see a sample image with this issue? > 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