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

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

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

    https://github.com/apache/nifi/pull/1356#discussion_r94050652
  
    --- Diff: 
nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java
 ---
    @@ -259,6 +270,14 @@ public void onScheduled(final ProcessContext context) 
throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    +        debugEnabled = getLogger().isDebugEnabled();
    +    }
    +
    +    @OnUnscheduled
    +    public void onUnScheduled() {
    +        defaultActions = null;
    --- End diff --
    
    This needs to be in the "OnStopped", not the "OnUnscheduled". 
"OnUnscheduled" will get executed once the user hits the "stop" button and 
there could still be threads running, leading to the NPE below. ("OnStopped" 
runs once all threads running the ontrigger have stopped)
    
    ![screen shot 2016-12-28 at 11 28 11 
am](https://cloud.githubusercontent.com/assets/11302527/21526179/39ea5e8c-ccf0-11e6-8653-a3d8e7e02f04.png)



> UpdateAttribute performance improvements
> ----------------------------------------
>
>                 Key: NIFI-3249
>                 URL: https://issues.apache.org/jira/browse/NIFI-3249
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Bryan Rosander
>            Assignee: Bryan Rosander
>            Priority: Minor
>         Attachments: after.png, before.png
>
>
> UpdateAttribute does a lot of work in every onTrigger() that it doesn't need 
> to.
> The default actions map can be built at schedule time so that it doesn't need 
> to be done on every trigger.
> getPropertyValue() can be implemented using ConcurrentMap.computeIfAbsent()
> Update actions can be ignored if there is a delete action for the same 
> attribute.
> Only need to call processSession.updateAttributes() and 
> processSession.deleteAttributes() if there are attributes to update and 
> delete respectively.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to