Skip to content

NIFI-5230: Fixed NPE in InvokeScriptedProcessor on customValidate#2734

Closed
mattyb149 wants to merge 1 commit intoapache:masterfrom
mattyb149:NIFI-5230
Closed

NIFI-5230: Fixed NPE in InvokeScriptedProcessor on customValidate#2734
mattyb149 wants to merge 1 commit intoapache:masterfrom
mattyb149:NIFI-5230

Conversation

@mattyb149
Copy link
Contributor

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:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

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.

Copy link
Contributor

@MikeThomsen MikeThomsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM. Running the scripting bundle tests now with contrib-check before merging.

@asfgit asfgit closed this in 23feb8f May 23, 2018
Copy link
Contributor

@ottobackwards ottobackwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using HashSet here, when we initialize to ArrayList initially? Shouldn't they be the same and consistent?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense. Thanks for the explanation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants