You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Lee Graber (JIRA)" <ji...@apache.org> on 2013/04/27 00:54:17 UTC

[jira] [Updated] (TIKA-1115) ExifHandler throws NullPointerException

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

Lee Graber updated TIKA-1115:
-----------------------------

    Attachment: 654000main_transit-hubble-orig_full.jpg

repro file
                
> ExifHandler throws NullPointerException
> ---------------------------------------
>
>                 Key: TIKA-1115
>                 URL: https://issues.apache.org/jira/browse/TIKA-1115
>             Project: Tika
>          Issue Type: Bug
>          Components: metadata
>    Affects Versions: 1.3
>         Environment: verified on Mac OSX and Ubuntu 12.04
>            Reporter: Lee Graber
>              Labels: ImageMetadataExtractor
>         Attachments: 654000main_transit-hubble-orig_full.jpg
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Notice that in the second if block, there is no check for null on the retrived datetime. I have hit this with a file which apparently has null for this value. Seems like the fix is trivial
> public void handleDateTags(Directory directory, Metadata metadata)
>                 throws MetadataException {
>             // Date/Time Original overrides value from ExifDirectory.TAG_DATETIME
>             Date original = null;
>             if (directory.containsTag(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL)) {
>                 original = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
>                 // Unless we have GPS time we don't know the time zone so date must be set
>                 // as ISO 8601 datetime without timezone suffix (no Z or +/-)
>                 if (original != null) {
>                     String datetimeNoTimeZone = DATE_UNSPECIFIED_TZ.format(original); // Same time zone as Metadata Extractor uses
>                     metadata.set(TikaCoreProperties.CREATED, datetimeNoTimeZone);
>                     metadata.set(Metadata.ORIGINAL_DATE, datetimeNoTimeZone);
>                 }
>             }
>             if (directory.containsTag(ExifIFD0Directory.TAG_DATETIME)) {
>                 Date datetime = directory.getDate(ExifIFD0Directory.TAG_DATETIME);
>                 String datetimeNoTimeZone = DATE_UNSPECIFIED_TZ.format(datetime);
>                 metadata.set(TikaCoreProperties.MODIFIED, datetimeNoTimeZone);
>                 // If Date/Time Original does not exist this might be creation date
>                 if (metadata.get(TikaCoreProperties.CREATED) == null) {
>                     metadata.set(TikaCoreProperties.CREATED, datetimeNoTimeZone);
>                 }
>             }
>         }

--
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