Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5584

Reorder if statement in DataTypeUtils.toTimestamp so that Timestamp comes before Date

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.7.1
    • 1.10.0
    • Core Framework
    • None
    • RHEL, JDK 8

    Description

      The method DataTypeUtils.toTimestamp in package nifi-record has the if statement structured as follows:

      public static Timestamp toTimestamp(final Object value, final Supplier<DateFormat> format, final String fieldName) {
      if (value == null) {
      return null;
      }
      
      if (value instanceof java.util.Date) {
      return new Timestamp(((java.util.Date)value).getTime());
      }
      
      if (value instanceof Timestamp) {
      return (Timestamp) value;
      }
      

      Since Timestamp extends java.util.Date a value of type timestamp always matches the 1st if statement and allocates a new timestamp object. The 1st if statement should check for timestamp followed by java.util.Date check.
       

      Attachments

        Issue Links

          Activity

            People

              mtien Margot Tien
              korir Gideon Korir
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: