Source:
private WorkflowInstance saveWorkflowInstanceState(StateExecutionImpl execution, WorkflowInstance instance, AbstractWorkflowDefinition<?> definition, WorkflowInstanceAction.Builder actionBuilder) { if (definition.getMethod(execution.getNextState()) == null && execution.getNextActivation() != null) { logger.debug("No handler method defined for {}, clearing next activation", execution.getNextState()); execution.setNextActivation(null); } WorkflowState nextState = definition.getState(execution.getNextState()); if (instance.parentWorkflowId != null && nextState.getType() == WorkflowStateType.end) { try { String parentType = workflowInstanceDao.getWorkflowInstanceType(instance.parentWorkflowId); AbstractWorkflowDefinition<? extends WorkflowState> parentDefinition = workflowDefinitions .getWorkflowDefinition(parentType); String[] waitStates = parentDefinition.getStates().stream() .filter(state -> state.getType() == WorkflowStateType.wait) .map(WorkflowState::name) .toArray(String[]::new); if (waitStates.length > 0) { execution.wakeUpParentWorkflow(waitStates); } } catch (@SuppressWarnings("unused") EmptyResultDataAccessException e) { } } WorkflowInstance.Builder instanceBuilder = new WorkflowInstance.Builder(instance) .setNextActivation(execution.getNextActivation()) .setStatus(getStatus(execution, nextState)) .setStateText(getStateText(instance, execution)) .setState(execution.getNextState()) .setRetries(execution.isRetry() ? execution.getRetries() + 1 : 0); do { try { return persistWorkflowInstanceState(execution, instance.stateVariables, actionBuilder, instanceBuilder); } catch (Exception ex) { logger.error("Failed to save workflow instance new state, retrying after seconds", instance.id, stateSaveRetryDelay, ex); sleepIgnoreInterrupted(stateSaveRetryDelay); } } while (!shutdownRequested.get()); throw new IllegalStateException(format("Failed to save workflow instance %s new state and shutdown requested", instance.id)); }

Target:
private WorkflowInstance saveWorkflowInstanceState(StateExecutionImpl execution, WorkflowInstance instance, AbstractWorkflowDefinition<?> definition, WorkflowInstanceAction.Builder actionBuilder) { if (definition.getMethod(execution.getNextState()) == null && execution.getNextActivation() != null) { logger.debug("No handler method defined for {}, clearing next activation", execution.getNextState()); execution.setNextActivation(null); } WorkflowState nextState = definition.getState(execution.getNextState()); if (instance.parentWorkflowId != null && nextState.getType() == WorkflowStateType.end) { try { String parentType = workflowInstanceDao.getWorkflowInstanceType(instance.parentWorkflowId); AbstractWorkflowDefinition<? extends WorkflowState> parentDefinition = workflowDefinitions .getWorkflowDefinition(parentType); String[] waitStates = parentDefinition.getStates().stream() .filter(state -> state.getType() == WorkflowStateType.wait) .map(WorkflowState::name) .toArray(String[]::new); if (waitStates.length > 0) { execution.wakeUpParentWorkflow(waitStates); } } catch (@SuppressWarnings("unused") EmptyResultDataAccessException e) { } } WorkflowInstance.Builder instanceBuilder = new WorkflowInstance.Builder(instance) .setNextActivation(execution.getNextActivation()) .setStatus(getStatus(execution, nextState)) .setStateText(getStateText(instance, execution)) .setState(execution.getNextState()) .setRetries(execution.isRetry() ? execution.getRetries() + 1 : 0); while (true) { try { return persistWorkflowInstanceState(execution, instance.stateVariables, actionBuilder, instanceBuilder); } catch (Exception ex) { if (shutdownRequested.get()) { logger.error("Failed to save workflow instance new state, not retrying due to shutdown request. The state will be rerun on recovery.", instance.id, ex); return instance; } logger.error("Failed to save workflow instance new state, retrying after seconds", instance.id, stateSaveRetryDelay, ex); sleepIgnoreInterrupted(stateSaveRetryDelay); } } }