Skip to content

NIFI-15840 Added rollback in ExecuteGroovyScript to allow script access to FlowFile.#11155

Merged
pvillard31 merged 2 commits into
apache:mainfrom
dan-s1:NIFI-15840
Apr 16, 2026
Merged

NIFI-15840 Added rollback in ExecuteGroovyScript to allow script access to FlowFile.#11155
pvillard31 merged 2 commits into
apache:mainfrom
dan-s1:NIFI-15840

Conversation

@dan-s1
Copy link
Copy Markdown
Contributor

@dan-s1 dan-s1 commented Apr 16, 2026

Summary

NIFI-15840
This PR fixes the bug in ExecuteGroovyScript so it should not fail with "Failure Strategy = transfer to failure" when there is a Groovy script that accesses a FlowFile.
In addition to this fix, this PR resolved some of the Intellij warnings.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@dan-s1 dan-s1 added the bug label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@pvillard31 pvillard31 left a comment

Choose a reason for hiding this comment

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

I do not believe this is correct/enough. Consider this test where it fails before we do the get in the script:

@Test
void testTransferToFailureStrategyWhereScriptFailsBeforeGet() {
    runner.setProperty(ExecuteGroovyScript.SCRIPT_BODY, """
            throw new RuntimeException("fail before get")
            """);
    runner.setProperty(ExecuteGroovyScript.FAIL_STRATEGY, ExecuteGroovyScript.TRANSFER_TO_FAILURE);
    runner.assertValid();
    runner.enqueue("test content".getBytes(StandardCharsets.UTF_8));
    runner.run();
    runner.assertAllFlowFilesTransferred(ExecuteGroovyScript.REL_FAILURE, 1);
}

Copy link
Copy Markdown
Contributor

@pvillard31 pvillard31 left a comment

Choose a reason for hiding this comment

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

Latest LGTM, thanks @dan-s1

@pvillard31 pvillard31 merged commit c43ee44 into apache:main Apr 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants