Gideon Korir created NIFI-5584:
----------------------------------

             Summary: Reorder if statement in DataTypeUtils.toTimestamp so that 
Timestamp comes before Date
                 Key: NIFI-5584
                 URL: https://issues.apache.org/jira/browse/NIFI-5584
             Project: Apache NiFi
          Issue Type: Improvement
          Components: Core Framework
    Affects Versions: 1.7.1
         Environment: RHEL, JDK 8
            Reporter: Gideon Korir


The method DataTypeUtils.toTimestamp in package nifi-record has the if 
statement structured as follows:
{code:java}
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;
}
{code}
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.
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to