Details

      Description

      InvokeScriptedProcessor pass his ValidationContext to the inner script, validate call

      InvokeScriptedProcessor Line 465 : final Collection<ValidationResult> instanceResults = instance.validate(context);

      The problem is that the invokedscript pass the ScriptFile PropertyDescriptor that is validated, if the script derived from the AbstractConfigurableComponent, (because the AbstractConfigurableComponent validate all the context properties).

      The context should be refined to remove the InvokeScriptedProcessor Properties.

        Issue Links

          Activity

          Hide
          frett27 Patrice Freydiere added a comment -

          When Script extends AbstractProcessor this exception is raised :

          [main] ERROR org.apache.nifi.processors.script.BaseScriptTest$AccessibleInvokeScriptedProcessor - [AccessibleInvokeScriptedProcessor[id=3d530126-78e2-4eab-94d1-9e81c1896c25]] Unable to validate the script Processor: java.lang.reflect.UndeclaredThrowableException
          java.lang.reflect.UndeclaredThrowableException
          at com.sun.proxy.$Proxy19.validate(Unknown Source)
          at org.apache.nifi.processors.script.InvokeScriptedProcessor.customValidate(InvokeScriptedProcessor.java:475)
          at org.apache.nifi.components.AbstractConfigurableComponent.validate(AbstractConfigurableComponent.java:126)
          at org.apache.nifi.util.MockProcessContext.validate(MockProcessContext.java:235)
          at org.apache.nifi.util.MockProcessContext.assertValid(MockProcessContext.java:252)
          at org.apache.nifi.util.StandardProcessorTestRunner.assertValid(StandardProcessorTestRunner.java:342)
          at org.apache.nifi.processors.script.TestInvokeGroovy.testAbstractProcessorImplementationWithBodyScriptFile(TestInvokeGroovy.java:190)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
          at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
          at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
          at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
          Caused by: javax.script.ScriptException: java.lang.NullPointerException
          at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:405)
          at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.access$100(GroovyScriptEngineImpl.java:98)
          at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$3.invoke(GroovyScriptEngineImpl.java:446)
          ... 32 more
          Caused by: java.lang.NullPointerException
          at java.io.File.<init>(Unknown Source)
          at org.apache.nifi.processor.util.StandardValidators$FileExistsValidator.validate(StandardValidators.java:784)
          at org.apache.nifi.components.PropertyDescriptor.validate(PropertyDescriptor.java:200)
          at org.apache.nifi.components.AbstractConfigurableComponent.validate(AbstractConfigurableComponent.java:116)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1210)
          at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
          at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:919)
          at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:902)
          at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:398)
          ... 34 more

          Show
          frett27 Patrice Freydiere added a comment - When Script extends AbstractProcessor this exception is raised : [main] ERROR org.apache.nifi.processors.script.BaseScriptTest$AccessibleInvokeScriptedProcessor - [AccessibleInvokeScriptedProcessor [id=3d530126-78e2-4eab-94d1-9e81c1896c25] ] Unable to validate the script Processor: java.lang.reflect.UndeclaredThrowableException java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy19.validate(Unknown Source) at org.apache.nifi.processors.script.InvokeScriptedProcessor.customValidate(InvokeScriptedProcessor.java:475) at org.apache.nifi.components.AbstractConfigurableComponent.validate(AbstractConfigurableComponent.java:126) at org.apache.nifi.util.MockProcessContext.validate(MockProcessContext.java:235) at org.apache.nifi.util.MockProcessContext.assertValid(MockProcessContext.java:252) at org.apache.nifi.util.StandardProcessorTestRunner.assertValid(StandardProcessorTestRunner.java:342) at org.apache.nifi.processors.script.TestInvokeGroovy.testAbstractProcessorImplementationWithBodyScriptFile(TestInvokeGroovy.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: javax.script.ScriptException: java.lang.NullPointerException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:405) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.access$100(GroovyScriptEngineImpl.java:98) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$3.invoke(GroovyScriptEngineImpl.java:446) ... 32 more Caused by: java.lang.NullPointerException at java.io.File.<init>(Unknown Source) at org.apache.nifi.processor.util.StandardValidators$FileExistsValidator.validate(StandardValidators.java:784) at org.apache.nifi.components.PropertyDescriptor.validate(PropertyDescriptor.java:200) at org.apache.nifi.components.AbstractConfigurableComponent.validate(AbstractConfigurableComponent.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1210) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:919) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:902) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:398) ... 34 more
          Hide
          frett27 Patrice Freydiere added a comment -

          using extends AbstractProcessor in a script lead to an exception, because the scripted class receive the invokescriptedprocessor properties,

          this patch fix this, and now permit to derive from helper base class opening the use to record based derivations, and making processing thought this.

          Show
          frett27 Patrice Freydiere added a comment - using extends AbstractProcessor in a script lead to an exception, because the scripted class receive the invokescriptedprocessor properties, this patch fix this, and now permit to derive from helper base class opening the use to record based derivations, and making processing thought this.
          Hide
          frett27 Patrice Freydiere added a comment -

          The patch for 4367

          Show
          frett27 Patrice Freydiere added a comment - The patch for 4367
          Hide
          joewitt Joseph Witt added a comment -

          removing fix version until we can get review traction on this.

          Show
          joewitt Joseph Witt added a comment - removing fix version until we can get review traction on this.
          Hide
          frett27 Patrice Freydiere added a comment -

          hi joseph, are there any things i could do to ease the review ?

          Show
          frett27 Patrice Freydiere added a comment - hi joseph, are there any things i could do to ease the review ?
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user frett27 opened a pull request:

          https://github.com/apache/nifi/pull/2201

          NIFI-4367 Fix on processor for permit deriving script classes from Ab…

          …stractProcessor or other Records based base classes

          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:

              1. For all changes:
          • [x] Is there a JIRA ticket associated with this PR? Is it referenced
            in the commit message?
          • [x] 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.
          • [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
          • [ ] Is your initial contribution a single, squashed commit?
              1. For code changes:
          • [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
          • [x] Have you written or updated unit tests to verify your changes?
          • [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
          • [x] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
          • [x] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
          • [x] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
              1. For documentation related changes:
          • [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
              1. 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.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/frett27/nifi nifi-4367

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/nifi/pull/2201.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #2201


          commit 3eec6c7a022a2424accc5d84f425b8746719c2d0
          Author: Patrice Freydiere <frett27@gmail.com>
          Date: 2017-09-09T14:43:14Z

          NIFI-4367 Fix on processor for permit deriving script classes from AbstractProcessor or other Records based base classes


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user frett27 opened a pull request: https://github.com/apache/nifi/pull/2201 NIFI-4367 Fix on processor for permit deriving script classes from Ab… …stractProcessor or other Records based base classes 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: [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? [x] 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. [x] 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: [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? [x] Have you written or updated unit tests to verify your changes? [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0] ( http://www.apache.org/legal/resolved.html#category-a)? [x] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? [x] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? [x] 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. You can merge this pull request into a Git repository by running: $ git pull https://github.com/frett27/nifi nifi-4367 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/2201.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2201 commit 3eec6c7a022a2424accc5d84f425b8746719c2d0 Author: Patrice Freydiere <frett27@gmail.com> Date: 2017-09-09T14:43:14Z NIFI-4367 Fix on processor for permit deriving script classes from AbstractProcessor or other Records based base classes

            People

            • Assignee:
              Unassigned
              Reporter:
              frett27 Patrice Freydiere
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development