flowable-engine icon indicating copy to clipboard operation
flowable-engine copied to clipboard

Incorrect log message for PlanItemInstanceState

Open mennotol opened this issue 3 years ago • 3 comments

Describe the bug The following cryptic log message appears when attempting to start a project:

org.flowable.common.engine.api.FlowableIllegalStateException: Can only enable a plan item instance which is in state ENABLED
	at org.flowable.cmmn.engine.impl.cmd.StartPlanItemInstanceCmd.internalExecute(StartPlanItemInstanceCmd.java:55) ~[flowable-cmmn-engine-6.7.2.jar:6.7.2]
	at org.flowable.cmmn.engine.impl.cmd.AbstractNeedsPlanItemInstanceCmd.execute(AbstractNeedsPlanItemInstanceCmd.java:101) ~[flowable-cmmn-engine-6.7.2.jar:6.7.2]
	at org.flowable.cmmn.engine.impl.cmd.AbstractNeedsPlanItemInstanceCmd.execute(AbstractNeedsPlanItemInstanceCmd.java:34) ~[flowable-cmmn-engine-6.7.2.jar:6.7.2]

Expected behavior A look at the code suggest the message should be: Can only enable a plan item instance which is not in state ENABLED

Code NA

Additional context Flowable 6.7.2, Spring boot 2.6.6

mennotol avatar Apr 19 '22 09:04 mennotol

The code in question is:

@Override
protected void internalExecute(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity) {
    if (!PlanItemInstanceState.ENABLED.equals(planItemInstanceEntity.getState())) {
        throw new FlowableIllegalStateException("Can only enable a plan item instance which is in state ENABLED");
    }
    CommandContextUtil.getAgenda(commandContext).planStartPlanItemInstanceOperation(planItemInstanceEntity, null,
            new ChildTaskActivityBehavior.VariableInfo(childTaskVariables, childTaskFormVariables, childTaskFormOutcome, childTaskFormInfo));
}

My reading of the code indicates that if the plan item instance has to be enabled as the exception is thrown only if the state is NOT enabled: if (!PlanItemInstanceState.ENABLED.equals(planItemInstanceEntity.getState())). Thus the message is correct about the plan item requiring to be in the ENABLED state to start it. It seems counter intuitive that you would want to start something that is not enabled, doesn't it?

dbmalkovsky avatar Apr 19 '22 12:04 dbmalkovsky

Perhaps confusion from my side. I expected that the state can only be ENABLED after the action that enables the plan item (in this case startPlanItemInstance). After calling startPlanItemInstance unintentionally for a second time I received the error. If the code intends that the state ENABLED is a condition for the action to enable the plan item, my apologies for the misunderstanding - although I still think a better log message would be more helpful.

On Tue, Apr 19, 2022 at 2:18 PM David B Malkovsky @.***> wrote:

The code in question is:

@Override protected void internalExecute(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity) { if (!PlanItemInstanceState.ENABLED.equals(planItemInstanceEntity.getState())) { throw new FlowableIllegalStateException("Can only enable a plan item instance which is in state ENABLED"); } CommandContextUtil.getAgenda(commandContext).planStartPlanItemInstanceOperation(planItemInstanceEntity, null, new ChildTaskActivityBehavior.VariableInfo(childTaskVariables, childTaskFormVariables, childTaskFormOutcome, childTaskFormInfo)); }

My reading of the code indicates that if the plan item instance has to be enabled as the exception is thrown only if the state is NOT enabled: if (!PlanItemInstanceState.ENABLED.equals(planItemInstanceEntity.getState())). Thus the message is correct about the plan item requiring to be in the ENABLED state to start it. It seems counter intuitive that you would want to start something that is not enabled, doesn't it?

— Reply to this email directly, view it on GitHub https://github.com/flowable/flowable-engine/issues/3280#issuecomment-1102574959, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYZNIY5DCZX4LCDNSU3RQPDVF2QAJANCNFSM5TYE2T7A . You are receiving this because you authored the thread.Message ID: @.***>

mennotol avatar Apr 19 '22 14:04 mennotol

Maybe the message should actually be "can only start a plan item instance which is in state ENABLED"?

tiffmaelite avatar Apr 22 '22 12:04 tiffmaelite