You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "M Tien (Jira)" <ji...@apache.org> on 2019/10/29 20:39:00 UTC
[jira] [Assigned] (NIFI-5584) Reorder if statement in
DataTypeUtils.toTimestamp so that Timestamp comes before Date
[ https://issues.apache.org/jira/browse/NIFI-5584?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
M Tien reassigned NIFI-5584:
----------------------------
Assignee: M Tien
> 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
> Assignee: M Tien
> Priority: Trivial
>
> 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
(v8.3.4#803005)