Source:
<code>public void process(final Object context) throws InterruptedException { UpdatableProcessInstance instance = (UpdatableProcessInstance) event.getProcessInstance(); String id = instance.getInstanceId(); ProcessInstanceManager instanceManager = WorkflowHub.getProcessInstanceManager(); Mutable<UpdatableHistoryStep> step = Mutable.of(null); <START> Transaction.performInOne(()-> { <END> UpdatableHistoryStep newStep = null; UpdatableProcessInstance processInstance = getProcessInstanceRepository().getById(id); if (!event.isFirstTimeSaved()) { newStep = (UpdatableHistoryStep) processInstance.getSavedStep(event.getUser().getUserId()); } else { newStep = (UpdatableHistoryStep) instanceManager.createHistoryStep(); newStep.setUserId(event.getUser().getUserId()); newStep.setAction(event.getActionName()); newStep.setActionDate(event.getActionDate()); newStep.setUserRoleName(event.getUserRoleName()); if (event.getResolvedState() != null) { newStep.setResolvedState(event.getResolvedState().getName()); } newStep.setActionStatus(0); newStep.setProcessInstance(processInstance); getHistoryStepRepository().save((HistoryStepImpl) newStep); } step.set(newStep); return newStep; }); Transaction.performInOne(()-> { UpdatableProcessInstance processInstance = getProcessInstanceRepository().getById(id); try { processEvent(processInstance, step.get().getId(), event.getResolvedState()); getProcessInstanceRepository().save((ProcessInstanceImpl) processInstance); } catch (WorkflowException we) { saveError(processInstance, event, step.get(), we); throw new WorkflowException("WorkflowEngineThread.process", "workflowEngine.EX_ERR_PROCESS_ADD_TASKSAVED_REQUEST", we); } return null; }); }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') Reduce this lambda expression number of lines 21 20. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public void process(final Object context) throws InterruptedException { UpdatableProcessInstance instance = (UpdatableProcessInstance) event.getProcessInstance(); String id = instance.getInstanceId(); ProcessInstanceManager instanceManager = WorkflowHub.getProcessInstanceManager(); Mutable<UpdatableHistoryStep> step = Mutable.of(null); Transaction.performInOne(()-> { UpdatableHistoryStep newStep = null; UpdatableProcessInstance processInstance = getProcessInstanceRepository().getById(id); if (!event.isFirstTimeSaved()) { newStep = (UpdatableHistoryStep) processInstance.getSavedStep(event.getUser().getUserId()); } else { newStep = (UpdatableHistoryStep) instanceManager.createHistoryStep(); newStep.setUserId(event.getUser().getUserId()); newStep.setAction(event.getActionName()); newStep.setActionDate(event.getActionDate()); newStep.setUserRoleName(event.getUserRoleName()); if (event.getResolvedState() != null) { newStep.setResolvedState(event.getResolvedState().getName()); } newStep.setActionStatus(0); newStep.setProcessInstance(processInstance); getHistoryStepRepository().save((HistoryStepImpl) newStep); } step.set(newStep); return newStep; }); Transaction.performInOne(()-> { UpdatableProcessInstance processInstance = getProcessInstanceRepository().getById(id); try { processEvent(processInstance, step.get().getId(), event.getResolvedState()); getProcessInstanceRepository().save((ProcessInstanceImpl) processInstance); } catch (WorkflowException we) { saveError(processInstance, event, we); throw new WorkflowException("WorkflowEngineThread.process", "workflowEngine.EX_ERR_PROCESS_ADD_TASKSAVED_REQUEST", we); } return null; }); }