You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/03/17 01:28:59 UTC

[GitHub] [nifi] mattyb149 opened a new pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

mattyb149 opened a new pull request #4903:
URL: https://github.com/apache/nifi/pull/4903


   Thank you for submitting a contribution to Apache NiFi.
   
   Please provide a short description of the PR here:
   
   #### Description of PR
   
   Some invalid Jython scripts succeed when compile() is called, and if a CompiledScript object is available (even if invalid), a changed script file or body will not be recompiled. For Jython the script shoukd be compiled every time init() is called on the Configurator. 
   
   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 `main`)?
   
   - [x] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### 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?
   - [x] Have you written or updated unit tests to verify your changes?
   - [x] Have you verified that the full build is successful on JDK 8?
   - [ ] Have you verified that the full build is successful on JDK 11?
   - [ ] 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)? 
   - [ ] 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 GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] pvillard31 commented on pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
pvillard31 commented on pull request #4903:
URL: https://github.com/apache/nifi/pull/4903#issuecomment-800871083


   I gave it a try based on JIRA's description. Will wait for @markap14's review.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
markap14 commented on pull request #4903:
URL: https://github.com/apache/nifi/pull/4903#issuecomment-800731861


   Thanks @mattyb149 will review


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on a change in pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
markap14 commented on a change in pull request #4903:
URL: https://github.com/apache/nifi/pull/4903#discussion_r601827461



##########
File path: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptEngineConfigurator.java
##########
@@ -50,7 +50,7 @@ public String getScriptEngineName() {
     @Override
     public Object init(ScriptEngine engine, String scriptBody, String[] modulePaths) throws ScriptException {
         // Always compile when first run
-        if (engine != null && compiledScriptRef.get() == null) {

Review comment:
       So this change would address the issue at hand, I believe, but it would do so at the expense of requiring that ExecuteScript would have to recompile the Jython script for every invocation of `onTrigger`. That could result in some extremely poor performance. I think we should instead leave this check in, but add an onPropertyModified method for the script components that is responsible for resetting the state here. So that way, we only need to recompile if a property is changed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 closed pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
markap14 closed pull request #4903:
URL: https://github.com/apache/nifi/pull/4903


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
markap14 commented on pull request #4903:
URL: https://github.com/apache/nifi/pull/4903#issuecomment-838816994


   @mattyb149 I tried this out with the latest commit, and it didn't appear to solve the underlying problem. There's no `onPropertyModified` to indicate that the script needs to be recompiled. I created a simple dataflow: GenerateFlowFile -> ExecuteScript -> UpdateAttribute. Configured ExecuteScript with the following script:
   ```
   flowfile = session.get()
   flowfile = session.putAttribute(flowfile, 'greeting', 'hello')
   session.transfer(flowfile, REL_SUCCESS)
   session.commit()
   ```
   
   It appeared to run correctly. Then I stopped the Processor, and changed the script to:
   ```
   flowfile = session.get()
   flowfile = session.putAttribute(flowfile, 'greeting', 'good-bye')
   session.transfer(flowfile, REL_SUCCESS)
   session.commit()
   ```
   
   Ran it again. The output had an attribute of `greeting` with a value of `hello` - NOT `good-bye`. So after I changed the text of the script, it did not recompile.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on pull request #4903: NIFI-8330: Fix compilation of Jython scripts for scripting components

Posted by GitBox <gi...@apache.org>.
markap14 commented on pull request #4903:
URL: https://github.com/apache/nifi/pull/4903#issuecomment-839157299


   Thanks @mattyb149, looking much better now! +1 merged to main! Thanks for knocking that out, definitely an important fix!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org