Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 26039 invoked from network); 21 Sep 2010 14:08:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Sep 2010 14:08:03 -0000 Received: (qmail 77730 invoked by uid 500); 21 Sep 2010 14:08:03 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76239 invoked by uid 500); 21 Sep 2010 14:07:59 -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 76224 invoked by uid 99); 21 Sep 2010 14:07:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 14:07:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 14:07:56 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8LE7YYP015428 for ; Tue, 21 Sep 2010 14:07:34 GMT Message-ID: <5995486.316231285078054273.JavaMail.jira@thor> Date: Tue, 21 Sep 2010 10:07:34 -0400 (EDT) From: "Alain (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (SANSELAN-44) JpegImageMetadata getEXIFThumbnail may raise a null pointer exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org JpegImageMetadata getEXIFThumbnail may raise a null pointer exception --------------------------------------------------------------------- Key: SANSELAN-44 URL: https://issues.apache.org/jira/browse/SANSELAN-44 Project: Commons Sanselan Issue Type: Bug Affects Versions: 0.94-incubator Reporter: Alain Fix For: 0.94-incubator A patch has been done to read thumbnail from exif metada (see bug 38). But there is a bug if exif is null (NullpointerException): public BufferedImage getEXIFThumbnail() throws ImageReadException, IOException { ArrayList dirs = exif.getDirectories(); for (int i = 0; i < dirs.size(); i++) { TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs .get(i); // Debug.debug("dir", dir); BufferedImage image = dir.getThumbnail(); if (null != image) return image; JpegImageData jpegImageData = dir.getJpegImageData(); if(jpegImageData!=null){ ByteArrayInputStream input = new ByteArrayInputStream(jpegImageData.data); image = ImageIO.read(input); if (image!=null) return image; } } return null; } This patch correct the bug: TiffImageMetadata exifs = jpegMetadata.getExif(); if (exifs != null) { ArrayList dirs = exifs.getDirectories(); for (int i = 0; i < dirs.size(); i++) { TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs.get(i); // Debug.debug("dir", dir); BufferedImage image = dir.getThumbnail(); if (null != image) { return image; } JpegImageData jpegImageData = dir.getJpegImageData(); if (jpegImageData != null) { ByteArrayInputStream input = new ByteArrayInputStream(jpegImageData.data); image = ImageIO.read(input); if (image != null) { return image; } } } } return null; -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.