Program: 56007
Project: 56007
Buggy source:
/** 
 * Returns a candidate vertex which could potentially be visited next because it is reachable from the currently considered vertex.
 * @param te the traversal entry for the current source vertex
 * @param forward <code>true</code> if the graph should be traversed in correct order, <code>false</code> to traverse it in reverse order
 * @return a candidate vertex which could potentially be visited next
 */
private ExecutionVertex getCandidateVertex(TraversalEntry te,boolean forward){
  if (forward) {
    while (true) {
      if (this.confinedToStage && te.getCurrentChannel() == 0) {
        while (currentGateLeadsToOtherStage(te,this.forward)) {
          te.increaseCurrentGate();
        }
      }
      if (te.getCurrentGate() >= te.getExecutionVertex().getEnvironment().getNumberOfOutputGates()) {
        break;
      }
      if (te.getCurrentChannel() >= te.getExecutionVertex().getEnvironment().getOutputGate(te.getCurrentGate()).getNumberOfOutputChannels()) {
        te.increaseCurrentGate();
        te.resetCurrentChannel();
      }
 else {
        final AbstractOutputChannel<? extends Record> outputChannel=te.getExecutionVertex().getEnvironment().getOutputGate(te.getCurrentGate()).getOutputChannel(te.getCurrentChannel());
        final ExecutionVertex tmp=executionGraph.getVertexByChannelID(outputChannel.getConnectedChannelID());
        if (tmp == null) {
          LOG.error("String_Node_Str");
        }
        te.increaseCurrentChannel();
        if (!alreadyVisited.contains(tmp)) {
          return tmp;
        }
      }
    }
  }
 else {
    while (true) {
      if (te.getCurrentGate() >= te.getExecutionVertex().getEnvironment().getNumberOfInputGates()) {
        break;
      }
      if (te.getCurrentChannel() >= te.getExecutionVertex().getEnvironment().getInputGate(te.getCurrentGate()).getNumberOfInputChannels()) {
        te.increaseCurrentGate();
        te.resetCurrentChannel();
      }
 else {
        final AbstractInputChannel<? extends Record> inputChannel=te.getExecutionVertex().getEnvironment().getInputGate(te.getCurrentGate()).getInputChannel(te.getCurrentChannel());
        final ExecutionVertex tmp=executionGraph.getVertexByChannelID(inputChannel.getConnectedChannelID());
        if (tmp == null) {
          LOG.error("String_Node_Str");
        }
        te.increaseCurrentChannel();
        if (!alreadyVisited.contains(tmp)) {
          return tmp;
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns a candidate vertex which could potentially be visited next because it is reachable from the currently considered vertex.
 * @param te the traversal entry for the current source vertex
 * @param forward <code>true</code> if the graph should be traversed in correct order, <code>false</code> to traverse it in reverse order
 * @return a candidate vertex which could potentially be visited next
 */
private ExecutionVertex getCandidateVertex(TraversalEntry te,boolean forward){
  if (forward) {
    while (true) {
      if (this.confinedToStage && te.getCurrentChannel() == 0) {
        while (currentGateLeadsToOtherStage(te,this.forward)) {
          te.increaseCurrentGate();
        }
      }
      if (te.getCurrentGate() >= te.getExecutionVertex().getEnvironment().getNumberOfOutputGates()) {
        break;
      }
      if (te.getCurrentChannel() >= te.getExecutionVertex().getEnvironment().getOutputGate(te.getCurrentGate()).getNumberOfOutputChannels()) {
        te.increaseCurrentGate();
        te.resetCurrentChannel();
      }
 else {
        final AbstractOutputChannel<? extends Record> outputChannel=te.getExecutionVertex().getEnvironment().getOutputGate(te.getCurrentGate()).getOutputChannel(te.getCurrentChannel());
        final ExecutionVertex tmp=this.executionGraph.getVertexByChannelID(outputChannel.getConnectedChannelID());
        if (tmp == null) {
          LOG.error("String_Node_Str");
        }
        te.increaseCurrentChannel();
        if (!this.alreadyVisited.contains(tmp)) {
          return tmp;
        }
      }
    }
  }
 else {
    while (true) {
      if (te.getCurrentGate() >= te.getExecutionVertex().getEnvironment().getNumberOfInputGates()) {
        break;
      }
      if (te.getCurrentChannel() >= te.getExecutionVertex().getEnvironment().getInputGate(te.getCurrentGate()).getNumberOfInputChannels()) {
        te.increaseCurrentGate();
        te.resetCurrentChannel();
      }
 else {
        final AbstractInputChannel<? extends Record> inputChannel=te.getExecutionVertex().getEnvironment().getInputGate(te.getCurrentGate()).getInputChannel(te.getCurrentChannel());
        final ExecutionVertex tmp=this.executionGraph.getVertexByChannelID(inputChannel.getConnectedChannelID());
        if (tmp == null) {
          LOG.error("String_Node_Str");
        }
        te.increaseCurrentChannel();
        if (!this.alreadyVisited.contains(tmp)) {
          return tmp;
        }
      }
    }
  }
  return null;
}