[jira] [Commented] (TIKA-1115) ExifHandler throws NullPointerException
[ https://issues.apache.org/jira/browse/TIKA-1115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13646713#comment-13646713 ] Lee Graber commented on TIKA-1115: -- No problem. It is a public domain image we were using to do some stress testing. > 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 >Assignee: Ray Gauss II > 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
[jira] [Commented] (TIKA-1115) ExifHandler throws NullPointerException
[ https://issues.apache.org/jira/browse/TIKA-1115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13646709#comment-13646709 ] Ray Gauss II commented on TIKA-1115: Hi Lee, Do we have permission to include the problem file at a greatly reduced size, say 64px wide, as a test 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 >Assignee: Ray Gauss II > 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