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

Matt Burgess commented on NIFI-8266:
------------------------------------

Decided to just implement the part when we validate the context's properties 
rather than what the component reports as supported properties. So it will 
likely validate a new InvokeScriptedProcessor before any script body/file is 
set, so only the existing 4 properties are added. Once properties are set, the 
validation context is recreated and will include any new properties defined by 
the script. It's a much cleaner and simpler solution and solves the NPE issue.

> InvokeScriptedProcessor can throw NPE during custom property validation
> -----------------------------------------------------------------------
>
>                 Key: NIFI-8266
>                 URL: https://issues.apache.org/jira/browse/NIFI-8266
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Matt Burgess
>            Priority: Major
>
> If a script in InvokeScriptedProcessor (ISP) specifies additional properties 
> to be added to the configuration dialog, a NullPointerException can occur 
> during validation:
> This appears to be the result of the ValidationContext for the ISP being 
> created before the script is loaded, and thus the properties are not present 
> in the context during validation. However the list iterated over in 
> AbstractConfigurableComponent.validate() is the list of supported property 
> descriptors, which may or may not include the script's properties when 
> validate() is called.
> The list to be iterated over should be the list of properties in the 
> ValidationContext, to avoid an NPE. Having said that, for components that can 
> provide properties dynamically (via script, e.g.) the ValidationContext 
> should be recreated rather than reusing the first one created. This could be 
> accomplished with a component annotation (ProvidesCustomProperties or 
> something). If the annotation exists for the component, the ValidationContext 
> should be recreated before validation; otherwise, the first one created 
> should be retained for performance purposes.



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

Reply via email to