NIFI-5230: Fixed NPE in InvokeScriptedProcessor on customValidate#2734
NIFI-5230: Fixed NPE in InvokeScriptedProcessor on customValidate#2734mattyb149 wants to merge 1 commit intoapache:masterfrom
Conversation
MikeThomsen
left a comment
There was a problem hiding this comment.
+1 LGTM. Running the scripting bundle tests now with contrib-check before merging.
ottobackwards
left a comment
There was a problem hiding this comment.
Couple of questions, if I may ask.
| @@ -237,7 +237,7 @@ public void setup() { | |||
| @Override | |||
| public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { | |||
|
|
|||
There was a problem hiding this comment.
Why are we using HashSet here, when we initialize to ArrayList initially? Shouldn't they be the same and consistent?
There was a problem hiding this comment.
Also, I don't understand customValidate. The validationResults are used to 'seed' the currentValidationResults, but if empty, any new validation results are not set back to validationResults. Is that right?
There was a problem hiding this comment.
@ottobackwards , when a processor is invalid (customValidate returned validation errors), we keep all the validationResults. Method 'customValidate' just check if there are already errors - no need to validate again, just return whatever is stored.
When any property is getting modified - these validation results may not be accurate anymore, so we have to reset them. Once reset (onPropertyModified), next call to customValidate will run full validation and set new errors if found. So at any point we don't drop validation results for no reason. Am I missing anything?
There was a problem hiding this comment.
Ok, that makes sense. Thanks for the explanation.
There was a problem hiding this comment.
@ottobackwards , regarding Set vs List. Validation Result supposed to be Collection, so technically - any of them can be used. But consistency should come with Set, as if you check super class AbstractConfigurableComponent, its customValidate returns:
return Collections.emptySet();
So, I would say, we need to refactor ArrayList into Set, but then there will be more potential regression impact. I'd recommend to keep it as is for this PR/Jira, and have another ticket opened on cosmetic improvement to change ArrayList to to some Set implementation during initialization. I hope it makes sense.
Thank you for submitting a contribution to Apache NiFi.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.