1 Reply Latest reply on Dec 13, 2008 3:21 PM by Ronald van Kuijk

    Decision Handler to result in default transition

    John Gemski Newbie

      We've run into a problem on upgrading from 3.1.4 to any version >= 3.2.3.

      Our DecisionHandler.decide used to return a null, which indicated to the Decision code to use the default transition.

      Upon upgrading, we're now getting:

      org.jbpm.JbpmException: decision 'mid' selected non existing transition 'null'
      at org.jbpm.graph.node.Decision.execute(Decision.java:91)
      at org.jbpm.graph.def.Node.enter(Node.java:318)
      at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
      .
      .
      .

      Looking at the code, it looks like this is no longer possible.

      In Decision.java

      String transitionName = decisionHandler.decide(executionContext);
      transition = getLeavingTransition(transitionName);
      if (transition == null) {
       throw new JbpmException("decision '" + name + "' selected non existing transition '" + transitionName + "'");
      }
      

      which prevents later code from running:

      if (transition == null) {
       transition = getDefaultLeavingTransition();
       log.debug("decision didn't select transition, taking default " + transition);
      }


      Was this intentionally taken away? Is there a way to accomplish the same behavior, which is to default the "default" transition if the DecisionHandler doesn't evaluate?

      Thanks,
      John

        • 1. Re: Decision Handler to result in default transition
          Ronald van Kuijk Master

           

          Was this intentionally taken away?

          I think it is, not sure


          Is there a way to accomplish the same behavior, which is to default the "default" transition if the DecisionHandler doesn't evaluate?


          I think not. Personally I'd have my decisionhandler return what I think should be the transition if no other can be selected. I never rely on in explicit 'default transitions'. In explicit in the sense that it is not explicitly declared in the process, but it is the bahaviour of jBPM. Suppose the 'definition' of default transition changes (which it will not easily, but you never know) then you have no clue why your process behaviour changes.

          Regarding the last code snippet, that is not for decisionhandlers or expressions (at least not anymore as you experience), but for the situation when conditions on transitions are used. If none of the conditions evaluates to true, the default transition is taken since a transition has to be taken. In a decisionhandler or expressions it is up to you to make sure one is taken