[ 
https://issues.apache.org/jira/browse/NIFI-9176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alex Sherwin updated NIFI-9176:
-------------------------------
    Description: 
The built-in {{org.apache.nifi.csv.CSVReader}} has a few startup methods 
annotated with {{@OnEnabled}}

The documentation for {{@OnEnabled}} doesn't specify the order they are invoked 
in, however it appears they are sorted alphabetically (at least they are in 
1.14.0, it may have been different in earlier versions, it looks like that 
behavior may have changed in 1.14.0)

The problem in {{CSVReader}} is that {{storeSchemaAccessStrategy}} runs before 
{{storeStaticProperties}} since its first alphabetically.

But, this is the wrong order.  The {{storeSchemaAccessStrategy}} depends on 
some values that {{storeStaticProperties}} sets up.

Unfortunately it doesn't look like {{@OnEnabled}} documents any guaranteed 
ordering (so, is the current alphabetical sorting just an undocumented 
implementation detail?)

So either {{storeStaticProperties}} needs to be renamed to come first 
alphabetically, or {{storeSchemaAccessStrategy}} needs to invoke 
{{storeStaticProperties}} before running it's business logic to ensure the 
required properties get setup first.

The bug manifests with things like inferring a CSV schema and setting a date 
format.  When the CSVReader starts up the first time, since the ordering is 
wrong, all date/time formatters get set to null.  If you restart the CSVReader 
service, it fixes itself, because NiFi re-uses the *same instance*, so the 
second time around, the local variables are already setup from the first start, 
and then it works normally.

  was:
The built-in {{org.apache.nifi.csv.CSVReader}} has a few startup methods 
annotated with {{@OnEnabled}}

The documentation for {{@OnEnabled}} doesn't specify the order they are invoked 
in, however it appears they are sorted alphabetically (at least they are in 
1.14.0, it may have been different in earlier versions, it looks like that 
behavior may have changed in 1.14.0)

The problem in {{CSVReader}} is that {{storeSchemaAccessStrategy}} runs before 
{{storeStaticProperties}} since its first alphabetically.

But, this is the wrong order.  The {{storeSchemaAccessStrategy}} depends on 
some values that {{storeStaticProperties}} sets up.

Unfortunately it doesn't look like {{@OnEnabled}} documents any guaranteed 
ordering (so, is the current alphabetical sorting just an undocumented 
implementation detail?)

So either {{storeStaticProperties}} needs to be renamed to come first 
alphabetically, or {{storeSchemaAccessStrategy}} needs to invoke 
{{storeStaticProperties}} before running it's business logic to ensure the 
required properties get setup first.

The bug manifests with things like inferring a CSV schema and setting a date 
format.  When the CSVReader starts up the first time, since the ordering is 
wrong, all date/time formatters get set to null.  If you restart the CSVReader 
service, it fixes itself, because NiFi re-uses the *same instance*, so the 
second time around, the local variables are already setup from the previous 
start, and then it works normally.


> CSVReader @OnEnabled initializes in wrong order
> -----------------------------------------------
>
>                 Key: NIFI-9176
>                 URL: https://issues.apache.org/jira/browse/NIFI-9176
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.14.0
>            Reporter: Alex Sherwin
>            Priority: Major
>
> The built-in {{org.apache.nifi.csv.CSVReader}} has a few startup methods 
> annotated with {{@OnEnabled}}
> The documentation for {{@OnEnabled}} doesn't specify the order they are 
> invoked in, however it appears they are sorted alphabetically (at least they 
> are in 1.14.0, it may have been different in earlier versions, it looks like 
> that behavior may have changed in 1.14.0)
> The problem in {{CSVReader}} is that {{storeSchemaAccessStrategy}} runs 
> before {{storeStaticProperties}} since its first alphabetically.
> But, this is the wrong order.  The {{storeSchemaAccessStrategy}} depends on 
> some values that {{storeStaticProperties}} sets up.
> Unfortunately it doesn't look like {{@OnEnabled}} documents any guaranteed 
> ordering (so, is the current alphabetical sorting just an undocumented 
> implementation detail?)
> So either {{storeStaticProperties}} needs to be renamed to come first 
> alphabetically, or {{storeSchemaAccessStrategy}} needs to invoke 
> {{storeStaticProperties}} before running it's business logic to ensure the 
> required properties get setup first.
> The bug manifests with things like inferring a CSV schema and setting a date 
> format.  When the CSVReader starts up the first time, since the ordering is 
> wrong, all date/time formatters get set to null.  If you restart the 
> CSVReader service, it fixes itself, because NiFi re-uses the *same instance*, 
> so the second time around, the local variables are already setup from the 
> first start, and then it works normally.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to