Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE when activating element inside flow scope that's being terminated #11083

Merged
1 commit merged into from
Nov 23, 2022

Conversation

remcowesterhoud
Copy link
Contributor

@remcowesterhoud remcowesterhoud commented Nov 23, 2022

Description

When a modify command contains an activate instruction for an element inside of a subprocess, and also a terminate instruction for the subprocess itself, Zeebe would run into a NullPointer.

This is caused by the fact that we keep track of the ancestor keys of an element that's getting activated. We need these to make sure we can clear the interrupted state from any of these ancestors. This is to ensure we support activating elements in an interrupted flow scope.

Since we first perform the activate instructions and after this the terminate instructions, we have already terminated the parent of the element that's being activated. We can not get the element instance and potentially remove the interrupted state. A null check needs to be added here.

Related issues

closes #10878

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2022

Test Results

   959 files  ±  0     959 suites  ±0   1h 43m 8s ⏱️ -45s
7 723 tests  - 92  7 716 ✔️  - 92  7 💤 ±0  0 ±0 
7 923 runs   - 92  7 914 ✔️  - 92  9 💤 ±0  0 ±0 

Results for commit 8766f41. ± Comparison against base commit 887b63b.

♻️ This comment has been updated with latest results.

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Thanks @remcowesterhoud LGTM 💯

Comment on lines +1121 to +1139
final var rejectedActivateCommand =
RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ACTIVATE_ELEMENT)
.withProcessInstanceKey(processInstanceKey)
.withElementId("endEvent")
.onlyCommandRejections()
.getFirst();

assertThat(rejectedActivateCommand.getRejectionType()).isEqualTo(RejectionType.INVALID_STATE);
assertThat(rejectedActivateCommand.getRejectionReason())
.isEqualTo(
"Expected flow scope instance with key '%s' to be present in state but not found.",
eventSubprocessKey);
assertThatElementIsTerminated(processInstanceKey, "eventSubProcess");
Copy link
Member

Choose a reason for hiding this comment

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

💭 Although the result is the same, this doesn't fully align with the expected behavior described in the issue:

I can apply the modification. As a result, the end event should be activated. But the whole event subprocess should be terminated because the activation instruction is applied before the termination instruction.

💭 This would be fixed in when Operate disallows this modification as part of Complex Process Instance Modification.

Copy link
Contributor Author

@remcowesterhoud remcowesterhoud Nov 23, 2022

Choose a reason for hiding this comment

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

I believe this is poor wording and it should say that the activate command should be written to the log, as it's an asynchronous action.

…at's being terminated

When a modify command contains an activate instruction for an element inside of a subprocess, and also a terminate instruction for the subprocess itself, Zeebe would run into a NullPointer.

This is caused by the fact that we keep track of the ancestor keys of an element that's getting activated. We need these to make sure we can clear the interrupted state from any of these ancestors. This is to ensure we support activating elements in an interrupted flow scope.

Since we first perform the activate instructions and after this the terminate instructions, we have already terminated the parent of the element that's being activated. We can not get the element instance and potentially remove the interrupted state. A null check needs to be added here.
@remcowesterhoud
Copy link
Contributor Author

bors merge

@ghost
Copy link

ghost commented Nov 23, 2022

Build succeeded:

@backport-action
Copy link
Collaborator

Successfully created backport PR #11087 for stable/8.1.

ghost pushed a commit that referenced this pull request Nov 23, 2022
11087: [Backport stable/8.1] Prevent NPE when activating element inside flow scope that's being terminated r=korthout a=backport-action

# Description
Backport of #11083 to `stable/8.1`.

relates to #10878

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
@remcowesterhoud remcowesterhoud added the version:8.1.5 Marks an issue as being completely or in parts released in 8.1.5 label Dec 6, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version:8.1.5 Marks an issue as being completely or in parts released in 8.1.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE in ProcessInstanceModifiedEventApplier
3 participants