Source:
<code>public void execute(ActivityExecution execution) throws Exception { PvmActivity activity = execution.getActivity(); List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); execution.inactivate(); lockConcurrentRoot(execution); List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity); List<ActivityExecution> finalExecutions = new ArrayList<ActivityExecution>(); Map<String, List<ActivityExecution>> mappedExecutions = mapExecutionsToTransitions(joinedExecutions, finalExecutions); List<PvmTransition> incomingTransitions = execution.getActivity().getIncomingTransitions(); for (PvmTransition incomingTransition : incomingTransitions) { List<ActivityExecution> sequenceExecutions = mappedExecutions.get(incomingTransition.getId()); if (sequenceExecutions == null || sequenceExecutions.isEmpty()){ <START> break; <END> } else { finalExecutions.add(sequenceExecutions.get(0)); } } int nbrOfExecutionsToJoin = incomingTransitions.size(); int nbrOfExecutionsJoined = finalExecutions.size(); if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) { log.fine("parallel gateway '"+activity.getId()+"' activates: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); execution.takeAll(outgoingTransitions, finalExecutions); } else if (log.isLoggable(Level.FINE)){ log.fine("parallel gateway '"+activity.getId()+"' does not activate: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); } }</code><technical_language>this work in case some executions a transition id set some not? Assuming following: A parallel join incoming sequence flows, a, b, c. executions: transition ID == null, transitiion ID == b, transition ID == c. assume incomingTransition in this loop is transition a. loop breaks finalExecutions contains execution. However, gateway fire executions for transitions b c. of fixing continue in loop break break if finalExecutions reached desired size. write a unit test for this case. set transition ID null, write a custom command in test manipulates field ExecutionEntity. I think, a case occur people upgrade Camunda running process instances execution 1 reached parallel gateway upgrade others upgrade</technical_language>

Target:
public void execute(ActivityExecution execution) throws Exception { PvmActivity activity = execution.getActivity(); List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); execution.inactivate(); lockConcurrentRoot(execution); List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity); List<ActivityExecution> finalExecutions = new ArrayList<ActivityExecution>(); Map<String, List<ActivityExecution>> mappedExecutions = mapExecutionsToTransitions(joinedExecutions, finalExecutions); List<PvmTransition> incomingTransitions = execution.getActivity().getIncomingTransitions(); int nbrOfExecutionsToJoin = incomingTransitions.size(); for (PvmTransition incomingTransition : incomingTransitions) { if(finalExecutions.size() == nbrOfExecutionsToJoin){ break; } List<ActivityExecution> sequenceExecutions = mappedExecutions.get(incomingTransition.getId()); if (sequenceExecutions != null && !sequenceExecutions.isEmpty()){ finalExecutions.add(sequenceExecutions.get(0)); } } int nbrOfExecutionsJoined = finalExecutions.size(); if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) { log.fine("parallel gateway '"+activity.getId()+"' activates: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); execution.takeAll(outgoingTransitions, finalExecutions); } else if (log.isLoggable(Level.FINE)){ log.fine("parallel gateway '"+activity.getId()+"' does not activate: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); } }