Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-1115

ExifHandler throws NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3
    • 1.4
    • metadata
    • verified on Mac OSX and Ubuntu 12.04

    Description

      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); }

      }
      }

      Attachments

        Activity

          People

            rgauss Ray Gauss II
            leegraber Lee Graber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified