diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java index b4cc54f91c7..3554997aeee 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java @@ -43,12 +43,6 @@ public UserTaskKogitoWorkItemHandlerProcessListener(Processes processes) { public void onUserTaskState(UserTaskStateEvent event) { UserTaskState userTaskState = event.getNewStatus(); - if (!userTaskState.isTerminate()) { - return; - } - - LOG.info("onUserTaskState {} on termination trigger {}", event, userTaskState); - String processId = (String) event.getUserTaskInstance().getMetadata().get("ProcessId"); String processInstanceId = (String) event.getUserTaskInstance().getMetadata().get("ProcessInstanceId"); ProcessInstance processInstance = processes.processById(processId).instances().findById(processInstanceId).orElse(null); @@ -56,6 +50,13 @@ public void onUserTaskState(UserTaskStateEvent event) { ((InternalKogitoWorkItem) workItem).setActualOwner(event.getUserTaskInstance().getActualOwner()); return workItem; }); + + if (!userTaskState.isTerminate()) { + return; + } + + LOG.info("onUserTaskState {} on termination trigger {}", event, userTaskState); + // we check first that the work item is not fished to convey the signal Boolean notify = (Boolean) event.getUserTaskInstance().getMetadata().get(DefaultUserTaskLifeCycle.PARAMETER_NOTIFY); if (notify != null && !notify) {