[ 
https://issues.apache.org/jira/browse/NIFI-4395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16175429#comment-16175429
 ] 

ASF GitHub Bot commented on NIFI-4395:
--------------------------------------

Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2166#discussion_r140349370
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractDatabaseFetchProcessor.java
 ---
    @@ -221,8 +222,12 @@ protected PropertyDescriptor 
getSupportedDynamicPropertyDescriptor(final String
             return super.customValidate(validationContext);
         }
     
    -    public void setup(final ProcessContext context) {
    -        final String maxValueColumnNames = 
context.getProperty(MAX_VALUE_COLUMN_NAMES).evaluateAttributeExpressions().getValue();
    +    public void setup(final ProcessContext context){
    +        setup(context,true,null);
    +    }
    +
    +    public void setup(final ProcessContext context, boolean 
shouldCleanCache,FlowFile flowFile) {
    +        final String maxValueColumnNames = (flowFile == null) ? 
context.getProperty(MAX_VALUE_COLUMN_NAMES).evaluateAttributeExpressions().getValue()
 : 
context.getProperty(MAX_VALUE_COLUMN_NAMES).evaluateAttributeExpressions(flowFile).getValue();
    --- End diff --
    
    I like the idea of being defensive, but flowFile can be null with 
`evaluateAttributeExpressions`, so we don't need this check using ternary 
operator. Just passing the flowFile (possibly null) is fine, as 
GenerateTableFetch [existing 
code](https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java#L185)
 does.


> GenerateTableFetch can't fetch column type by state after instance reboot
> -------------------------------------------------------------------------
>
>                 Key: NIFI-4395
>                 URL: https://issues.apache.org/jira/browse/NIFI-4395
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 1.3.0
>            Reporter: Deon Huang
>            Assignee: Deon Huang
>             Fix For: 1.4.0
>
>         Attachments: GenerateTableFetch_Exception.png
>
>
> The problem can easily be reproduce.
> Once GenerateTableFetch store state and encounter NiFi instance reboot.
> (Dynamic naming table by expression language)
> The exception will occur.
> The error in source code is list below.
> ```
>     if (type == null) {
>     // This shouldn't happen as we are populating columnTypeMap when the 
> processor is scheduled or when the first maximum is observed
>     throw new IllegalArgumentException("No column type found for: " + 
> colName);
>     }
> ```
> When this situation happened. The FlowFile will also be grab and can't 
> release or observed.
> Processor can't grab existing  column type from *columnTypeMap* through 
> instance reboot.
> Hence will inevidible get this exception, rollback FlowFile and never success.
> QueryDatabaseTable processor will not encounter this exception due to it 
> setup(context) every time,
> While GenerateTableFetch will not pass the condition and thus try to fetch 
> column type from 0 length columnTypeMap.
> ---
>     if (!isDynamicTableName && !isDynamicMaxValues) {
>     super.setup(context);
>     }
> ---
> I can take the issue if it is recognize as bug.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to